By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

Threading, How Control.Invoke() works

P: n/a
LVP

Hello,

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?

Thank you,

LVP
Dec 18 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Dec 18 '07 #2

P: n/a
LVP
Hi Pete,

I am not looking into deep details but, a bit more detail than you provided
me.

A high level diagram of how things work would be great.

Links would be great also.

Thank you,

LVP

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
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

Dec 18 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.