Home »

How do I use the thread pool?

Question ListCategory: ASP.NETHow do I use the thread pool?
shah_kajal184 author asked 1 year ago
1 Answers
denielshakespeare5 author answered 10 months ago

By passing an instance of a WaitCallback delegate to theThreadPool.QueueUserWorkItem() method
class CApp
static void Main(){
string s = “Hello, World”;
ThreadPool.QueueUserWorkItem( new WaitCallback( DoWork ), s );
Thread.Sleep( 1000 ); // Give time for work item to be executed
// DoWork is executed on a thread from the thread pool.
static void DoWork( object state ){
Console.WriteLine( state );

Please login or Register to Submit Answer