when you create the thread, try to set its IsBackground = true BackgroundTest longTest = new BackgroundTest(50);Thread backgroundThread = new Thread(new ThreadStart(longTest.RunLoop)); backgroundThread.Name = "BackgroundThread";backgroundThread.IsBackground = true;backgroundThread.Start();
BackgroundTest longTest = new BackgroundTest(50);Thread backgroundThread =
new Thread(new ThreadStart(longTest.RunLoop));
backgroundThread.Name = "BackgroundThread";backgroundThread.IsBackground = true;backgroundThread.Start();
2、尽量在dispose中关闭你的线程程序。Thread.Abort()
3、最好将线程中的while的条件设置成可以更改的true/false,推出的时候也可以用这个停止线程序
2、尽量在dispose中关闭你的线程程序。Thread.Abort()
3、最好将线程中的while的条件设置成可以更改的true/false,推出的时候也可以用这个停止线程序
Thread.CurrentThread.Abord();================================================================
巅峰之道,高瞻才能远瞩;
实力之道,厚积而薄发;东莞打工者创业论坛:
http://211.148.133.100/work/
================================================================
Application.ExitThread();
Application.Exit();另外建议你在窗体的close代码里面添加thread.Abort();
[email protected]
你可以将线程的IsBackground属性设置为true,使其变为后台线程,
后台线程在主程序结束时会自动中止,也就不会出现你说的那个情况了,这是初学线程很容易碰到的问题