title: Using ProgressMonitorDialog in Eclipse 4 properly
body: <p>I have a set of APIs that do file operations e.g. <code>saveToFile(CustomObject objectToSave);</code>  </p>
  
  <p>Since a file operation could be lengthy I decided that some indication should be shown to the user e.g. progress bar.  </p>
  
  <p>I read about a <code>ProgressMonitorDialog</code> and so I tried it, but it doesn't exactly work as I need (or better I don't know how to use it properly).  </p>
  
  <p>Currently I do:  </p>
  
  <pre><code>ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(theShell);  
      try {  
          progressDialog.run(false, true, new IRunnableWithProgress() {  
  
          @Override  
          public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {  
              monitor.beginTask("Saving your data", 100);  
              try {  
                  Utils.saveToFile(objectToSave);  
              } catch (Exception e) {  
              // TODO Auto-generated catch block  
                  e.printStackTrace();  
              }  
              monitor.done();   
          }  
       });   
  </code></pre>
  
  <p>This code shows a progress dialog very fast and ends, but the problem is that on a slower PC this would stack until the <code>Utils.saveToFile</code> returned, while I have no idea how to indicate intermediate process until the save is completed.</p>
  
  <p>I found a <a href="https://stackoverflow.com/questions/7636020/how-can-i-correctly-update-a-progress-bar-for-an-operation-of-unknown-duration-w">thread</a> mentioning about <code>IProgressMonitor.UNKNOWN</code> but it does not say about what happens in <code>monitor</code> during the <code>performRead(_fileName, monitor);</code></p>
  
  <p>How would I solve this?  </p>