摘要:
C#老生常谈之AutoResetEvent和ManualResetEvent一:终止状态和非终止状态 首先说说线程的终止状态和非终止状态。AutoResetEvent和ManualResetEvent的构造函数中,都有bool变量来指明线程的终止状态和非终止状态。true表示终止状态,false表示非终止状态。看代码片段1:代码片段1: AutoResetEvent _autoResetEvent = new AutoResetEvent(false); private void BT_Temp_Click(object sender, RoutedEventArgs e) { Thread 阅读全文
posted @ 2012-07-26 17:10
Danny Chen
阅读(266)
评论(0)
推荐(0)
摘要:
C#中的AutoResetEvent和ManualResetEvent用于实现线程同步。其基本工作原理是多个线程持有同一个XXXResetEvent,在这个XXXResetEvent未被set前,各线程都在WaitOne()除挂起;在这个XXXResetEvent被set后,所有被挂起的线程中有一个(AutoResetEvent的情况下)或全部(ManualResetEvent的情况下)恢复执行。AutoResetEvent与ManualResetEvent的差别在于某个线程在WaitOne()被挂起后重新获得执行权时,是否自动reset这个事件(Event),前者是自动reset的,后者不是 阅读全文
posted @ 2012-07-26 17:10
Danny Chen
阅读(5835)
评论(0)
推荐(0)

浙公网安备 33010602011771号