static bool DoWithTimeout(Action action, int timeout) { EventWaitHandle waitHandle = new EventWaitHandle (false, EventResetMode.ManualReset); AsyncCallback callback = ar => waitHandle.Set(); action.BeginInvoke( callback, null ); return (waitHandle.WaitOne( timeout )); }