public static bool Wait(object obj, TimeSpan timeout, bool exitContext) { try { if (exitContext) SynchronizationAttribute.ExitContext (); return Wait (obj, timeout); } finally { if (exitContext) SynchronizationAttribute.EnterContext (); } }
public void Invoke(Action action) { // Execute now if already on the thread if (Thread.CurrentThread == _thread) { action(); } else { lock (action) { // Schedule action InvokeLater(action); // Wait for action to complete ThreadMonitor.Wait(action); } } }