Thread-safe updates of a WinForm control from other classes

前端 未结 4 999
不思量自难忘°
不思量自难忘° 2021-01-13 15:20

Could someone please help me with the following problem:

There are two classes MainForm and LWriter. Below is a method from the LWriter that in addition to writing

4条回答
  •  走了就别回头了
    2021-01-13 16:15

    As suggested by Sonu, delegate can be used for Thread safe calls, and you can use Linq to shorten the code:

    this.BeginInvoke( (Action) delegate ()
    {
           //code to update UI
    });
    

    See this link for more information.

提交回复
热议问题