private void TriggerWaitCalledNewThread(int? timeout, bool? exitContext, ref bool cancel) { WaitEventArgs args = new WaitEventArgs(timeout, exitContext); Thread t = new Thread(new ThreadStart(delegate { SafeTrigger(BeforeWaitCalled, this, args); if (args.CancelWait) { ArgumentException exception = new ArgumentException("You can't cancel a call to WaitOne() without setting AllowWaitCanceling to true"); ThreadManager.exceptions.Add(exception); throw exception; } })); t.Start(); }
private void TriggerWaitCalledSameThread(int? timeout, bool? exitContext, ref bool cancel) { WaitEventArgs args = new WaitEventArgs(timeout, exitContext); SafeTrigger(BeforeWaitCalled, this, args); if (args.CancelWait) { cancel = true; } }