Use AutoResetEvent : AutoResetEvent « Thread « C# / C Sharp






Use AutoResetEvent

using System;
using System.Threading;

// AutoReset
class Auto {
    [STAThread]
    static void Main() {
        AutoResetEvent aRE = new AutoResetEvent(true);
        bool state = aRE.WaitOne(1000, true);
        Console.WriteLine("After First WaitOne " + state);
        state = aRE.WaitOne(5000, true);
        Console.WriteLine("After Second WaitOne " + state);
    }
}

           
       








Related examples in the same category