嗨,大家好,我開始線程這樣的代碼:如何停止線程?
Thread[] thr;
private void button1_Click(object sender, EventArgs e)
{
decimal value = numericUpDown2.Value;
int i = 0;
threads_count = (int)(value);
thr = new Thread[threads_count];
for (; i < threads_count; i++)
{
thr[i] = new Thread(new ThreadStart(go));
thr[i].IsBackground = true;
thr[i].Start();
}
}
如何停止所有的人,如果我的條件成爲真正的
您可以發佈中'go'代碼以及 – 2013-02-11 17:27:45
的常用方法停止線程結束的線程中運行代碼。 – 2013-02-11 17:30:52
它可能有幫助http://stackoverflow.com/questions/1764898/how-do-i-safely-stop-ac-sharp-net-thread-running-in-a-windows-service – exexzian 2013-02-11 17:34:57