What's wrong with calling Invoke, regardless of InvokeRequired?

前端 未结 6 1509
春和景丽
春和景丽 2020-12-08 13:38

I\'ve seen the common setup for cross threading access to a GUI control, such as discussed here: Shortest way to write a thread-safe access method to a windows forms control

6条回答
  •  粉色の甜心
    2020-12-08 14:00

    InvokeRequired basically tells you if you're executing on the right thread or not. If you're not on the correct thread, you need to marshal the task to the correct thread otherwise you don't. Hence the need for the check.

提交回复
热议问题