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

前端 未结 6 1506
春和景丽
春和景丽 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:50

    The Invoke is going to call the code through Delegate and not directly which would be costly.

    Its cost effective to call Invoke only when it required. Hence, InvokeRequired is used to find out is the call being made from same thread or another thread?

提交回复
热议问题