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

C# Smartthreadpool如何知道何时完成所有线程?,c#,multithreading,C#,Multithreading,我正在试图弄清楚如何知道队列中的所有线程何时完成。。完成后,我想显示一个消息框,上面写着“操作完成” 这是我用来为线程排队的代码: Smart.STPStartInfo stpStartInfo = new Smart.STPStartInfo(); stpStartInfo.MaxWorkerThreads = Convert.ToInt32(numericUpDown5.Value); stpStartInfo.MinWorkerThreads = 2; _smartThreadPool =

我正在试图弄清楚如何知道队列中的所有
线程何时完成。。完成后,我想显示一个
消息框
,上面写着“操作完成”

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

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++;
}
Smart.STPStartInfo STPStartInfo=new Smart.STPStartInfo();
stpStartInfo.MaxWorkerThreads=Convert.ToInt32(numericUpDown5.Value);
stpStartInfo.MinWorkerThreads=2;
_smartThreadPool=new Smart.smartThreadPool(stpStartInfo);
foreach(urlQueue中的字符串项)
{
_smartThreadPool.QueueWorkItem(
新的Amib.Threading.Func(checkURLSmart),
项目,iia,5000,氪文本框1.文本);
iia++;
}

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

您可以在SmartThreadPool上使用WaitAll或WaitAny


什么版本的.NET以及为什么要使用(智能)线程池?任务(TPL)是否可用?我正在使用.NET4.0。不确定什么是TPL:/Duplicate post:如果不停止GUI,我将如何做到这一点?您将不得不等待另一个线程或任务。和我的答案一样。然后使用Control.Invoke显示结果。