c# - Execute simple Logic without "locking" the UI -


i have dialog txb's , button. when button clicked want change button's text, disable button, start logic , close window.

that logic has no return, sets static variable. can take minute because connects db.

how can stop winfroms ui freezing? i'm looking simple approach, if possible no new classes , files.

here's do:

private async void buttonclick()  {     //here, you're on ui thread     button1.enabled = false;      await task.run(() => dothework());      //you're on ui thread     button1.enabled = true; }  private void dothework()  {     //this executed on different thread } 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -