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

ThreadPool or BeginInvoke()?

I'm writing an application invoking asynchon methods.

I envision using the .NET thread pool since it matches
well my needs.

There is (at least) 2 methods to do that:
using ThreadPool class directely or using the BeginInvoke
() of a delegate.

Does anybody knows any advantages from one method to
another?

thank you

Nov 16 '05 #1
2 3625
fred <an*******@discussions.microsoft.com> wrote:
I'm writing an application invoking asynchon methods.

I envision using the .NET thread pool since it matches
well my needs.

There is (at least) 2 methods to do that:
using ThreadPool class directely or using the BeginInvoke
() of a delegate.

Does anybody knows any advantages from one method to
another?


See http://www.pobox.com/~skeet/csharp/t...readpool.shtml for
detailed comments, but:

o QueueUserWorkItem only allows a single parameter, of type object
o QueueUserWorkItem doesn't allow you to specify a callback
o QueueUserWorkItem doesn't require EndInvoke or anything similar

(The reverse is true for BeginInvoke in each case.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
thank you.

I did not see that
QueueUserWorkItem doesn't allow you to specify a callback

this is enough to convinct me for using BeginInvoke()

thank you
-----Original Message-----
fred <an*******@discussions.microsoft.com> wrote:
I'm writing an application invoking asynchon methods.

I envision using the .NET thread pool since it matches
well my needs.

There is (at least) 2 methods to do that:
using ThreadPool class directely or using the BeginInvoke () of a delegate.

Does anybody knows any advantages from one method to
another?
See

http://www.pobox.com/~skeet/csharp/t...hreadpool.shtm
l fordetailed comments, but:

o QueueUserWorkItem only allows a single parameter, of type objecto QueueUserWorkItem doesn't allow you to specify a callbacko QueueUserWorkItem doesn't require EndInvoke or anything similar
(The reverse is true for BeginInvoke in each case.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

Nov 16 '05 #3

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

Similar topics

11
by: AA | last post by:
Why microsoft make so hard to change the max Pool Size?? I really need to change it to 50, because I'm using delegates with BeginInvoke and I saw that they (delegates) use the ThreadPool, but I...
2
by: Mark Hoffman | last post by:
All, My application spawns a worker process by calling BeginInvoke with an asynchronous callback method. This callback method is responsible for calling EndInvoke. No problems there; pretty much...
3
by: SSonnenwald | last post by:
I have created a piece of code that uses a ThreadPool class and the QueueUserWorkItem method to add items to the the ThreadPool. What would seem to be simple I just can not figure out how to tell...
6
by: Max Adams | last post by:
Threads and ThreadPool's If I use a ThreadPool how can I tell when a thead in the threadpool has exited? I don't want to set a global member variable I would much rather be able to act on an...
7
by: Novice | last post by:
I come from the land of Java and C++** where it is relatively easy to create a pool of threads, send them off to a task, then call the join method and await all of their completion. However, I...
13
by: orekin | last post by:
Hi There I have been programming C# for a couple of months and am trying to master Threading. I understand that ThreadPool uses background threads (see code example in MSDN page titled...
10
by: Lenn | last post by:
Hello, I have always used a certain design pattern for multithreaded Windows app; Start new worker thread from UI thread, use events to notify UI threads when something happens, update UI...
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: =?Utf-8?B?cmJEZXZlbG9wZXI=?= | last post by:
The following is from a simple Windows application in VS2005, which has button1 and textbox1 dragged onto a form. In StartThreads(), I call ThreadPool.QueueUserWorkItem(), then call WaitOne()....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.