ふらっとC#,C♯,C#(初心者用) Part39
■ このスレッドは過去ログ倉庫に格納されています
0601596
2009/04/01(水) 17:28:085スレッドまで。1秒待っても駄目だったら混雑中。
private volatile static Semaphore _pool = new Semaphore(0, 5);
static Default() {_pool.Release(5); }
protected void Page_Load(object sender, EventArgs e)
{
if (!_pool.WaitOne(1000))
{
Response.Write("混雑しています。");
Response.End();
}
try
{
Response.Redirect(URL);
}
finally
{
Thread t = new Thread(() => {
Thread.Sleep(10 * 1000);
int cnt = _pool.Release();
System.Diagnostics.Debug.WriteLine("cnt " + cnt);});
t.Start();
System.Diagnostics.Debug.WriteLine("finally");
}
}
}
■ このスレッドは過去ログ倉庫に格納されています