2016年11月26日

摘要: //如果你的应用有很多线程,这些线程大部分时间都在阻塞,那么可以通过调用ThreadPool.RegisterWaitForSingleObject来减少资源消耗。这个方法接受一个委托,它会在向等待句柄发信号时执行。当处于等待状态时,它不会浪费线程资源: static ManualResetEvent _starter = new ManualResetEvent (false); publi... 阅读全文
posted @ 2016-11-26 22:36 听哥哥的话 阅读(320) 评论(0) 推荐(0) 编辑
摘要: using System; using System.Threading; using System.Collections.Generic; class ProducerConsumerQueue : IDisposable { EventWaitHandle _wh = new AutoResetEvent (false); Thread _worker; readonly o... 阅读全文
posted @ 2016-11-26 22:05 听哥哥的话 阅读(764) 评论(0) 推荐(0) 编辑
摘要: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApplication46 { class TwoWaySignaling... 阅读全文
posted @ 2016-11-26 21:38 听哥哥的话 阅读(826) 评论(0) 推荐(0) 编辑

导航