static void Main(string[] args) { Console.WriteLine("Starting program..."); Thread t = new Thread(PrintNumbersWithDelay); t.Start(); Thread.Sleep(TimeSpan.FromSeconds(6)); t.Abort(); // 此处运行报错 Console.WriteLine("A thread has been aborted"); Console.ReadLine(); } static void PrintNumbersWithDelay() { Console.WriteLine("Starting..."); for (int i = 1; i < 10; i++) { Thread.Sleep(TimeSpan.FromSeconds(2)); Console.WriteLine(i); } }
netcore中不支持多线程的Abort
猜你喜欢
转载自www.cnblogs.com/25miao/p/12726095.html
今日推荐
周排行