欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

c# 启动线程的方式

程序员文章站 2022-07-10 21:43:03
//不带参数的启动方式 scanThread = new Thread(new ThreadStart(startThread)); scanThread.IsBackground = true; scanThread.Start(); //带参数的启动方式 endThread = new Thre ......

 

//不带参数的启动方式

scanThread = new Thread(new ThreadStart(startThread));
scanThread.IsBackground = true;
scanThread.Start();

 

//带参数的启动方式

endThread = new Thread(new ParameterizedThreadStart(endThread));
endThread.IsBackground = true;
endThread.Start(param);

 

ThreadPool.QueueUserWorkItem(new WaitCallback(startThread), param);