public void schedule(DebuggerCommandImpl managerCommand) {
   if (myEvents.isClosed()) {
     managerCommand.notifyCancelled();
   } else {
     super.schedule(managerCommand);
   }
 }
 public void invokeAndWait(DebuggerCommandImpl managerCommand) {
   LOG.assertTrue(!ApplicationManager.getApplication().isDispatchThread());
   LOG.assertTrue(
       !(currentThread() instanceof DebuggerManagerThreadImpl),
       "Should be invoked outside manager thread, use DebuggerManagerThreadImpl.getInstance(..).invoke...");
   super.invokeAndWait(managerCommand);
 }
 public void pushBack(DebuggerCommandImpl managerCommand) {
   if (myEvents.isClosed()) {
     managerCommand.notifyCancelled();
   } else {
     super.pushBack(managerCommand);
   }
 }
  public void startLongProcessAndFork(Runnable process) {
    startNewWorkerThread();

    try {
      process.run();
    } finally {
      final WorkerThreadRequest request = getCurrentThreadRequest();

      if (LOG.isDebugEnabled()) {
        LOG.debug("Switching back to " + request);
      }

      super.invokeAndWait(
          new DebuggerCommandImpl() {
            protected void action() throws Exception {
              switchToRequest(request);
            }

            protected void commandCancelled() {
              if (LOG.isDebugEnabled()) {
                LOG.debug("Event queue was closed, killing request");
              }
              request.interrupt();
            }
          });
    }
  }