473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Threading, How Control.Invoke() works

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
2 3144
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Z D | last post by:
Hello, I'm having a strange problem that is probably due to my lack of understanding of how threading & COM Interop works in a WinForms.NET application. Here's the situation: I have a 3rd...
2
by: Ludovic SOEUR | last post by:
Have everyone tried to create controls in separated threads ? I have a problem that I do not understand. To simplify the explanations, I wrote theses few lines to show an example of the problem....
13
by: RCS | last post by:
I have a UI that needs a couple of threads to do some significant processing on a couple of different forms - and while it's at it, update the UI (set textboxes, fill in listviews). I created a...
3
by: Elliot Rodriguez | last post by:
Hi: I am writing a WinForm app that contains a DataGrid control and a StatusBar control. My goal is to update the status bar using events from a separate class, as well as some other simple...
6
by: John Rugo | last post by:
Hi All, I have the most basic understanding of using Threading. I have no problem creating a thread, addressing it to a Sub Procedure, and Starting the Thread. Works Great! My problem is the...
0
by: Pawan Narula via DotNetMonster.com | last post by:
hi all, i'm using VB.NET and trying to code for contact management in a tree. all my contacts r saved in a text file and my C dll reads them one by one and sends to VB callback in a sync mode...
14
by: Christian Kaiser | last post by:
We have a component that has no window. Well, no window in managed code - it uses a DLL which itself uses a window, and this is our problem! When the garbage collector runs and removes our...
8
by: WhiteWizard | last post by:
I guess it's my turn to ASK a question ;) Briefly my problem: I am developing a Windows app that has several User Controls. On one of these controls, I am copying/processing some rather large...
7
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has...
9
by: tshad | last post by:
I have a Windows App that is doing some work and then writing a "Now Processing..." line to the status line of the window as well as the Textbox on the form. But the problem is that the work is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.