Smartthreadpool如何知道所有线程何时完成?

时间:2012-10-10 18:29:27

标签: c# multithreading

我试图弄清楚如何找出队列中的所有threads何时完成...当它们完成时我想显示MessageBox类似“操作已完成”的内容。< / p>

这是我用来排队我的线程的代码:

Smart.STPStartInfo stpStartInfo = new Smart.STPStartInfo();
stpStartInfo.MaxWorkerThreads = Convert.ToInt32(numericUpDown5.Value);
stpStartInfo.MinWorkerThreads = 2;
_smartThreadPool = new Smart.SmartThreadPool(stpStartInfo);

foreach (string item in urlQueue)
{
    _smartThreadPool.QueueWorkItem(
        new Amib.Threading.Func<string, int, int, string, int>(checkURLSmart),
                                item, iia, 5000, kryptonTextBox1.Text);

    iia++;
}

如何知道所有线程何时完成工作?

1 个答案:

答案 0 :(得分:0)

您可以在SmartThreadPool上使用WaitAll或WaitAny。

http://www.codeproject.com/Articles/7933/Smart-Thread-Pool#Feature4

相关问题