March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System;
using System.Threading;
namespace Samples
{
public class WaitHandle
{
static AutoResetEvent threadDone =
new AutoResetEvent(false);
public static void StartHere()
{
Console.WriteLine("Starting thread");
Thread.Sleep(1000);
threadDone.Set();
Console.WriteLine("Finishing thread");
}
public static void Main()
{
Console.WriteLine("Starting Main");
Thread t = new Thread(
new ThreadStart(StartHere));
t.Start();
threadDone.WaitOne();
threadDone.Close();
Console.WriteLine("Finishing Main");
}
}
}
Starting Main Starting thread Finishing Main Finishing thread
Read now
Unlock full access