Csharp/C Sharp/Development Class/ManualResetEvent
ManualResetEvent: Reset
using System;
using System.Threading;
class Reset {
[STAThread]
static void Main() {
ManualResetEvent manRE;
manRE = new ManualResetEvent(true);
bool state = manRE.WaitOne(1000, true);
Console.WriteLine(state);
manRE.Reset();
state = manRE.WaitOne(5000, true);
Console.WriteLine(state);
}
}
ManualResetEvent: Set
using System;
using System.Threading;
class ManualSet{
[STAThread]
static void Main(string[] args) {
ManualResetEvent manRE = new ManualResetEvent(false);
bool state = manRE.WaitOne(5000, true);
Console.WriteLine("ManualResetEvent After first WaitOne " + state);
manRE.Set();
state = manRE.WaitOne(5000, true);
Console.WriteLine("ManualResetEvent After second WaitOne " + state);
}
}
ManualResetEvent.WaitOne
using System;
using System.Threading;
public class NonSignaledManual {
public static void Main() {
ManualResetEvent mansig = new ManualResetEvent(false);
Console.WriteLine("ManualResetEvent Before WaitOne ");
bool b = mansig.WaitOne(1000, false);
Console.WriteLine("ManualResetEvent After WaitOne " + b);
}
}