Solved

DEFINITION: Different between Delegate.BeginInvoke and Thread.Start()

Posted on 2004-08-28
4
898 Views
Last Modified: 2008-03-03
If I have a method of type

public void myMethod()
{

}

And I create a delegate void NewDelegate(void)

What is the actual difference between the following calls and how they are handled by .NET and the OS

NewDelegate del = NewDelegate(myMethod);
del.BeginInvoke(null, null);

and

Thread t = new Thread(new ThreadStart(myMethod));
t.Start();

I know the delegate will use a thread from the thread pool, but will the thread t as well?  What is the actual effect of one versus the other.
0
Comment
Question by:jjacksn
4 Comments
 
LVL 2

Accepted Solution

by:
shaival_trivedi earned 250 total points
ID: 11919788
0
 
LVL 37

Assisted Solution

by:gregoryyoung
gregoryyoung earned 250 total points
ID: 11921282
it will create a new thread delegate.begininvoke will not it will be queued into the thread pool.

however there are some caveats within the CLR that make the thread not necesarily exclusively owned.

If you look at the thread class you will read "Note   An operating-system ThreadId has no fixed relationship to a managed thread, because an unmanaged host can control the relationship between managed and unmanaged threads. Specifically, a sophisticated host can use the CLR Hosting API to schedule many managed threads against the same operating system thread, or to move a managed thread between different operating system threads." this pretty much says it all.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
System.Security 2 27
Set value of dynamically created checkboxlist 2 33
Graphics 2 28
C# LINQ ForEach() question 6 28
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question