using System.Threading; class Program { static void Main(string[] args) { ManualResetEvent eventToWaitOn = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(DoWork, eventToWaitOn); bool signaled = eventToWaitOn.WaitOne(5000); // Wait for 5 seconds if (!signaled) { // Handle timeout scenario here throw new TimeoutException("Operation timed out after 5 seconds"); } // Continue with further processing } static void DoWork(object state) { // Simulate doing some work that takes time Thread.Sleep(3000); ManualResetEvent eventToSignal = (ManualResetEvent)state; eventToSignal.Set(); } }In this example, the Main thread creates a new ManualResetEvent, then kicks off some work on a background thread via ThreadPool.QueueUserWorkItem(). It then waits for up to 5 seconds for the event to be signaled using WaitOne(), passing in a timeout value. If the event is not signaled within 5 seconds, the WaitOne() call will return false and the program will throw a TimeoutException. Meanwhile, the DoWork method simulates doing some work that takes 3 seconds to complete, then signals the event using Set(). This allows the Main thread to proceed with further processing. The System.Threading namespace is part of the .NET Framework Base Class Library (BCL).