473,395 Members | 1,738 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,395 software developers and data experts.

Towards Understanding BeginInvoke()

What all does the delegate class' BeginInvoke() do?

I have been reading up on it, and it appears to me that it does the
following:
1. creates a new thread
2. executes the method(s) referenced by the delegate on that thread
3. immediately returns so the caller (of BeginInvoke()) can go on with it's
life.

But I suspect the above is an over-simplification.

I'm a bit fuzzy on step 1 above, and how the method(s) referenced by the
delegate actually begin executing on the new/other thread. Is the thread
pool somehow involved in this?

Thanks!
Sep 13 '07 #1
2 1178
On Sep 13, 4:44 pm, "Frankie" <A...@B.COMwrote:
What all does the delegate class' BeginInvoke() do?

I have been reading up on it, and it appears to me that it does the
following:
1. creates a new thread
2. executes the method(s) referenced by the delegate on that thread
3. immediately returns so the caller (of BeginInvoke()) can go on with it's
life.

But I suspect the above is an over-simplification.
Yes - instead, it basically queues a work item on the system thread
pool to execute the delegate.

Jon

Sep 13 '07 #2
http://msdn.microsoft.com/msdnmag/is...urrentAffairs/

you can look at codes in this article and see how delegate's BeginInvoke
would work.

Bob

"Jon Skeet [C# MVP]" wrote:
On Sep 13, 4:44 pm, "Frankie" <A...@B.COMwrote:
What all does the delegate class' BeginInvoke() do?

I have been reading up on it, and it appears to me that it does the
following:
1. creates a new thread
2. executes the method(s) referenced by the delegate on that thread
3. immediately returns so the caller (of BeginInvoke()) can go on with it's
life.

But I suspect the above is an over-simplification.

Yes - instead, it basically queues a work item on the system thread
pool to execute the delegate.

Jon

Sep 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: bazad | last post by:
Hi, I'd like to understand consequences of Application.DoEvents call. Does it create a new thread? Thank you
6
by: arkam | last post by:
Hi, I found a sample on internet : formMain.BeginInvoke(new MyClickHandler(this.OnMyClick)); I would like to do the same but in a class library where there is no forms ! Where can I find...
9
by: David Sworder | last post by:
Hi, I have a form that displays data (is that vague enough for you?). The data comes in on a thread-pool thread. Since the thread pool thread is not the same as the UI thread, the callback...
9
by: john doe | last post by:
I have a question about BeginInvoke method found on the Control class. To quote the docs: "Executes the specified delegate asynchronously with the specified arguments, on the thread that the...
3
by: RWF | last post by:
I have a windows form of which I will be saving the user's selections from DropDownBoxes, CheckBoxes, and RadioButtons. Once the choices are collected, I really will have no use for any of the...
2
by: Flack | last post by:
Hello, If I understand BeginInvoke correctly, when it is called your delegate is run on a thread pool thread. Now, if you supplied a callback delegate, that too is called on the same thread...
2
by: =?Utf-8?B?a2VubmV0aG1Abm9zcGFtLm5vc3BhbQ==?= | last post by:
vs2005, c# Trying to understand why one way works but the other doesnt. I have not tried to create a simpler mdi/child/showdialog app for posting purposes (I think even this would not be so small...
5
by: FP | last post by:
Hi, i'm currently developing a class to communicate with a serial device,using the SerialPort component. Basically,the main application will interact with this class through its method "Call",the...
7
by: Ben Voigt [C++ MVP] | last post by:
As much as the CLR team assures us that it's ok to fire-and-forget Control.BeginInvoke, it seems it isn't. Maybe this is a bug. See for example: the comments in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...

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.