Cross-thread problems with .NET data binding

后端 未结 1 485
孤独总比滥情好
孤独总比滥情好 2021-01-21 09:34

I have a number of Windows Forms controls which are used to interact with my program objects. Currently they subscribe to an \"Updated\" event on the object and manually update

相关标签:
1条回答
  • 2021-01-21 09:56

    If you are data binding your controls to the data sources that are being updated from the underlying thread, then you will have to move the code that does the updating to the UI thread through a call to Invoke.

    Or, if you want, you could get a ISynchronizeInvoke implementation (or a SynchronizationContext) and have all the events fire on the UI thread. Of course, this could cause unintended problems with your code, as you weren't firing the events on the UI thread in the first place.

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