i use such code
List<Thread> list = new List<Thread>();
Thread newThread = new Thread(delegate() { stream(string); });
this.list.Add(newThread);
newThread.Start();
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
foreach (var item in list)
{
item.Abort();
}
}
but after closing the process still runs in task manager, how can i exit whole app?
i googled many times, but all examples are much hard to understand for me
Use the debugger. Attach it if necessary with Tools + Attach to Process. Debug + Break All, Debug + Windows + Threads shows you what threads are still running. Use the Thread.IsBackground property to keep your code behind the left door .
退出应用程序:
Application.Exit();
foreach (Thread t in threads) t.Join();
If you run your thread as a background thread the thread will be stoped when you exit your main application like this:
Thread newThread = new Thread(delegate() { stream(string); });
this.list.Add(newThread);
newThread.isBackground = true;
newThread.Start();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.