zoukankan      html  css  js  c++  java
  • netcore中不支持多线程的Abort

     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);
                }
            }
  • 相关阅读:
    数学考试
    奇♂妙拆分
    11.25
    11.21
    11.20
    11.19
    11.18
    11.15
    11.14作业
    11.14
  • 原文地址:https://www.cnblogs.com/25miao/p/12726095.html
Copyright © 2011-2022 走看看