WPF的Application.Current.Shutdown()与Environment.Exit(0)区别
程序员文章站
2022-03-01 13:04:29
...
Task.Factory.StartNew(() =>
{
Thread.CurrentThread.IsBackground = false;
for (int i = 0; i < 1000; i++)
{
Thread.Sleep(1000);
string s = i + " ";
}
});
//①,Application.Current.Shutdown();
//②,Environment.Exit(0);
1、当 Thread.CurrentThread.IsBackground = false; 时 ①只关掉了UI而后台进程没有关掉;
2、当 Thread.CurrentThread.IsBackground = true; 时 ①②都可以关掉UI和进程。