using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
AutoResetEvent aRE = new AutoResetEvent(true);
bool state = aRE.WaitOne(1000, true); //等待一秒後,執行下面一行
Console.WriteLine("After First State " + state);
aRE.Set(); //重新設定訊號
state = aRE.WaitOne(5000, true);
if (state)
{
//在五秒內取得訊號
}
else
{
//等於或超過五秒,沒有收到訊號
}
Console.WriteLine("After Second State" + state);
}
}
}
2010年5月15日 星期六
AutoResetEvent範例
在文字的世界裡尋找心靈的共鳴,遠山藍以溫柔的筆觸分享書籍的力量與生活的智慧。無論是細膩的書評、深刻的人生感悟,還是技術與創新的新奇發現,每篇文章都是一次內心的療癒旅程。希望透過閱讀,帶領讀者在忙碌的生活中找到一片寧靜與啟發。讓我們一起,在書香中遇見更好的自己!
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言