开发者

C# : whats the use of waitHandle when we can use the threadPool Property

Whats the trade off b开发者_如何学Goetween using waitHandle and using threadPool's Property Thread.CurrentThread.IsThreadPoolThread ? Considering the fact my methods in threadpool are brief ? does it makes sense to use waitHandle to consider it not waiting ?

ThreadPool.QueueUserWorkItem(delegate
                             {
                                 DoWork(Top, Bottom);
                             });

if (Thread.CurrentThread.IsThreadPoolThread == false 
                      && SomeotherCondition == false )
{
    // Uses the Dowork
}

Redefining the questions: when should one use waitHandle and when IsThreadPoolThread?


Use a WaitHandle when you want a thread to wait for some operation to complete. Use IsThreadPoolThread when you want to know if a thread is a thread pool thread. To put it another way, use a rocket if you want to go into space, and make a salad if you want to eat vegetables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜