title: Return the value of an object created in a runSync method
body: <p>I have a class that extends the <code>MessageConsole</code> class which expects an instance of it's super constructur <code>super(String name, ImageDescriptor imgDescriptor)</code>. The method used to create the <code>ImageDescriptor</code> is bellow:</p>
  
  <p><code>ImageDescriptor.createFromImage(Activator.getImage(SharedImages.SPECIFIC_IMAGE));</code></p>
  
  <p>This method randomly causes <code>org.eclipse.swt.SWTError: Invalid thread access</code> because at the moment it is called, the workbench may or may not be initiated.</p>
  
  <p>I read <a href="https://wiki.eclipse.org/FAQ_Why_do_I_get_an_invalid_thread_access_exception%3F" rel="nofollow noreferrer">here</a> that I need to run the function in <code>sync</code> or <code>async</code> mode in order to properly perform actions on the UI, therefore I create the method bellow:</p>
  
  <pre><code>private static ImageDescriptor createImageDescriptor() {
      Activator.getMyService().runSync(new Runnable() {
  
          public void run() {
             ImageDescriptor.createFromImage(Activator.getImage(SharedImages.JUSTIFICATION));
          }
      });
  
      return null;
  }
  </code></pre>
  
  <p><code>runSync</code> is a wrapper of the <code>syncExec</code>, which adds some checks before calling it. You can consider <code>syncExec</code> instead of <code>runSync</code>.<br>
  How could I return the value of the created <code>ImageDescriptor</code> so I can pass it to the <code>super</code> constructor?</p>