On Tue, 18 Dec 2007 10:06:42 -0800, LVP <lv**********@hotmail.comwrote:
How does Control.Invoke(delegate) work?
Executes the specified delegate on the thread that owns the control's
underlying window handle
I am looking for Underthehood explanation.
How do Threads talk to each other? Who is the Middle Woman/Man/Machine?
How much detail do you need/want?
I don't know all of the implementation details, but I can tell you that it
uses the message queue to marshal the delegate execution to the desired
thread. BeginInvoke() just puts a message in the queue along with the
necessary data that causes the control instance upon receiving the message
to actually run the delegate with the supplied parameters (if any).
Invoke() is similar, except that the calling thread is synchronized with
the execution of the delegate so that it doesn't continue until the
control's thread has actually run the delegate.
You can use Reflector to see the exact details, I believe. Alternatively,
Microsoft said they would be releasing the .NET source code for use in
debugging. I haven't been following that, but if it's not out yet it
should be soon. Then you can look at all the details directly (but it
should be like what you see in Reflector, just with perhaps better names
and comments).
Pete