Events raised by BackgroundWorker not executed on expected thread

前端 未结 1 1059
孤城傲影
孤城傲影 2020-12-20 08:20

A winforms dialog is using BackgroundWorker to perform some asynchronous operations with significant success. On occasion, the async process being run by the background work

相关标签:
1条回答
  • 2020-12-20 08:45

    The BackgroundWorker will raise its ProgressChanged event and RunWorkerCompleted event on the UI thread (more accurately, it will post them to the thread using the currently established SynchronizationContext.)

    But it will not simply enable you to raise arbitrary events on the UI thread. For that you should access the SynchronizationContext.Current and use the Post method.

    0 讨论(0)
提交回复
热议问题