Updating UI from events using asyc await

前端 未结 4 1464
北海茫月
北海茫月 2020-12-31 00:16

I am trying to understand how to update a UI from an event while using async/await pattern. Below is the test code I am using on a WinForm app. I am not even sure this is th

4条回答
  •  生来不讨喜
    2020-12-31 00:57

    //Just declare a delegate like so

    delegate void Add(string msg);
    

    //Then declare the delegate method like so:

    var add = new Add((msg) => {
       _listBox_Output.Items.Add(msg);
    });
    

    //Now just call the delegate:

    void pwe_StatusUpdate(string updateMsg)
        {
    
          _listBox_Output.Invoke(add,updateMsg);
        }
    

提交回复
热议问题