Towards Understanding BeginInvoke()

F

Frankie

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!
 
J

Jon Skeet [C# MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top