title: Cancel button in ProgressMonitorDialog and InvocationTargetException
body: <p>In my application, I generate a report. Time of the operation is from a few seconds to up to several hours. To inform the user I use <code>ProgressMonitorDialog</code>. 
  Always after about 70 minutes <code>InvocationTargetException</code> is thrown. I have no idea why this is happening.   </p>
  
  <pre><code>  try {
      new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() {
          @Override
          public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
              monitor.beginTask("Something...", IProgressMonitor.UNKNOWN);
              controller.generate(model);
              monitor.done();
          }
      });
  } catch (InvocationTargetException | InterruptedException e) {
      logger.error(e);
  }
  </code></pre>
  
  <p>Stack Trace:</p>
  
  <pre><code>java.lang.reflect.InvocationTargetException
      at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
      at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
      at pl.edu.prz.allegroapi.gui.report.ProductReport$4.widgetSelected(ProductReport.java:323)
      at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
      at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
      at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
      at pl.edu.prz.allegroapi.gui.report.ProductReport.open(ProductReport.java:91)
      at pl.edu.prz.allegroapi.gui.MainWindow$2.widgetSelected(MainWindow.java:126)
      at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
      at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
      at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
      at pl.edu.prz.allegroapi.gui.MainWindow.open(MainWindow.java:75)
      at pl.edu.prz.allegroapi.tasks.CreateGuiTask.doStartup(CreateGuiTask.java:46)
      at pl.edu.prz.allegroapi.tasks.CreateGuiTask.access$0(CreateGuiTask.java:42)
      at pl.edu.prz.allegroapi.tasks.CreateGuiTask$1.run(CreateGuiTask.java:31)
      at java.lang.Thread.run(Unknown Source)
  Caused by: org.eclipse.swt.SWTException: Invalid thread access
      at org.eclipse.swt.SWT.error(Unknown Source)
      at org.eclipse.swt.SWT.error(Unknown Source)
      at org.eclipse.swt.SWT.error(Unknown Source)
      at org.eclipse.swt.widgets.Widget.error(Unknown Source)
      at org.eclipse.swt.widgets.Widget.checkWidget(Unknown Source)
      at org.eclipse.swt.widgets.Dialog.checkParent(Unknown Source)
      at org.eclipse.swt.widgets.Dialog.&lt;init&gt;(Unknown Source)
      at org.eclipse.swt.widgets.MessageBox.&lt;init&gt;(Unknown Source)
      at pl.edu.prz.allegroapi.gui.report.ProductReportController.generate(ProductReportController.java:59)
      at pl.edu.prz.allegroapi.gui.report.ProductReport$4$1.run(ProductReport.java:335)
      at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
  </code></pre>
  
  <p>The second problem is the cancellation of the window with the progress of work. I know that pressing the "cancel" button, the method <code>isCanceled()</code> returns true. I tried the following solution, but it can not work because the variable exit would be final.</p>
  
  <pre><code>Boolean exit = false;
  display.asyncExec(new Runnable() {
      public void run() {
          controller.generate(model);
          exit=true;
      }
  });
  try {
      new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() {
          @Override
          public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
              try {
                  monitor.beginTask("Something...", IProgressMonitor.UNKNOWN);
                  while(!monitor.isCanceled() &amp;&amp; !exit) {
                      Thread.sleep(1000);
                  }
              } finally {
                  monitor.done();
              }
          }
      });
  } catch (InvocationTargetException | InterruptedException e) {
      e.printStackTrace();
  }
  </code></pre>