打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
C#ThreadPool线程池操作

C#ThreadPool线程池操作

(2013-02-07 09:36:32)
       static void Main(string[] args)
       {
           // Queuethe task.
          ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc));

          Console.WriteLine("Main thread does some work, thensleeps.");
           // If youcomment out the Sleep, the main thread exits before
           // thethread pool task runs.  The thread pool usesbackground
           //threads, which do not keep the application running. (This
           // is asimple example of a race condition.)
          Thread.Sleep(1000);

          Console.WriteLine("Main thread exits.");

          Console.Read();
       }

       // This thread procedure performs thetask.
       static void ThreadProc(Object stateInfo)
       {
           // Nostate object was passed to QueueUserWorkItem,so 
           //stateInfo is null.
          Console.WriteLine("Hello from the thread pool.");
       }
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
C#多线程学习 之 线程池[ThreadPool]
C#多线程编程简述
线程(一)——线程,线程池,Task概念+代码实践
autoEvent.WaitOne(1000,true)第二个参数啥作用啊,有高手知道吗?
多线程编程笔记(二) - 流浪者的专栏
5天不再惧怕多线程——第五天 线程池
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服