using System.Threading; public class MyThread { static EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); public static void WorkerThread() { // Do some work waitHandle.Set(); } }
using System.Threading; public class MyThread { static EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); public static void Main() { // Start worker thread Thread t = new Thread(new ThreadStart(WorkerThread)); t.Start(); // Wait for worker thread to complete waitHandle.WaitOne(); } public static void WorkerThread() { // Do some work waitHandle.Set(); } }In this example, the main thread starts a worker thread and then waits for it to complete. The worker thread calls the Set method on the waitHandle object once its work is done, causing the main thread to proceed. The System.Threading namespace is used in both examples, indicating that the package library is likely part of the .NET Framework.