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

前端 未结 6 1467
春和景丽
春和景丽 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 13:59

    If you try to invoke before a window handle is created (for example, when calling form constructor), you will get an InvalidOperationException. So, generally InvokeRequired check is required.

    See MSDN for details.

提交回复
热议问题