一个父级有几个子线程。
如果用户单击停止按钮,则父线程应与所有子线程一起被杀死。
//calls a main thread
mainThread = new Thread(new ThreadStart(startWorking));
mainThread.Start();
////////////////////////////////////////////////
startWorking()
{
ManualResetEventInstance = new ManualResetEvent(false);
ThreadPool.SetMaxThreads(m_ThreadPoolLimit, m_ThreadPoolLimit);
for(int i = 0; i < list.count ; i++)
{
ThreadData obj_ThreadData = new ThreadData();
obj_ThreadData.name = list[i];
m_ThreadCount++;
//execute
WaitCallback obj_waitCallBack = new WaitCallback(startParsing);
ThreadPool.QueueUserWorkItem(obj_waitCallBack, obj_ThreadData);
}
ManualResetEventInstance.WaitOne();
}
我想杀死主线程。