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
Post a Comment