tags:

views:

575

answers:

1

I'm attempting to create a bare bones app for use in developing a plugin. I don't need a workbench.

Below the title1 dialog will show, but the title2 never does.

What needs to be done in order for the 2nd one to be shown?

public class BareBonesApp extends AbstractApplication
{
    public Object start(IApplicationContext context) throws Exception
    {
     Display display = PlatformUI.createDisplay();

     MessageDialog.openWarning(null, "title1", "message1");

     display.asyncExec(new Runnable()
     {
      public void run()
      {
       MessageDialog.openWarning(null, "title2", "message2");
      }
     });

     return null;
    }
}
A: 

Display has different queues for runnables that should run sync, async or in a specifc time (Display.timerExec). When Display.readAndDispatch has dispatched all events, first the runnables in the sync-queue are executed, then the async-queue is emptied and after that the due timerExec runnables are executed.

The only difference between Display.syncExec and Display.asyncExec is that the syncExec method waits for the runnable to be executed by the Display thread. Display.asyncExec simply queues the runnable and goes on.

So if "title2" never appears, I asume your application does not run the Display loop:

Display display = new Display(); // this thread should be the only one that creates a display instance
while (someCondition) {
  if (!display.readAndDispatch())
    display.sleep();
}
ftl

related questions