How does Invoke work underneath? Doesn't thread have only 1 instruction pointer?

前端 未结 1 1986
逝去的感伤
逝去的感伤 2021-01-04 14:12

I would like to know how it is possible that C# Invoke function can work (I am now considering the call from worker thread to invoke a method that manipulates GUI from GUI t

1条回答
  •  萌比男神i
    2021-01-04 14:47

    It sends a a Window message to the target thread. The thread must be in a message loop for Invoke to work. When the thread gets the message, it calls the delegate.

    No cross-thread IP changes are necessary - in fact, changing the IP would almost definitely crash the target thread.

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