Execute a delegate in the ui thread (using message pump)

后端 未结 5 1624
抹茶落季
抹茶落季 2020-12-19 16:18

I have a background thread that handles communication with an external service. Each time the background thread receives a message I\'d like to pass it to the UI thread for

5条回答
  •  囚心锁ツ
    2020-12-19 16:58

    If your GUI thread has blocked and does not process any messages, you could use Application.DoEvents to force the GUI thread to process all awaiting messages on that thread.

    To pump messages to the thread of the Control, certainly you can use the Control.BeginInvoke or Control.Invoke methods but note that Control.Invoke will block if the owning thread of the Control is currently blocking.

提交回复
热议问题