class Program
    {
        static void Main(string[] args)
        {          
            Work work = new Work();

             //两种实例化委托的方法;
            //ParameterizedThreadStart ParameterizedThreadStartDelegate = new ParameterizedThreadStart(work.DoWork);
            ParameterizedThreadStart ParameterizedThreadStartDelegate = work.DoWork;
            Thread thread = new Thread(ParameterizedThreadStartDelegate);
            thread.Start(5);      //参数
            Console.ReadKey();
         }
    }

        public void DoWork(Object t)
        {
            for (int i = 0; i <= (int)t; i++)
            {
                Console.WriteLine("请打印{0}\n", i);
            }
        }

 

此例犯错原因:ParameterizedThreadStart和ThreadStart不要重新定义委托。

相关文章:

  • 2022-02-08
  • 2022-12-23
  • 2022-01-27
  • 2021-06-09
  • 2021-06-14
猜你喜欢
  • 2021-08-14
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2021-09-12
  • 2022-02-03
相关资源
相似解决方案