Java Code Examples for org.eclipse.swt.widgets.Display#wake()

The following examples show how to use org.eclipse.swt.widgets.Display#wake() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobRunner.java    From http4e with Apache License 2.0 5 votes vote down vote up
public void run(){
   // main swt thread
   final Display display = Display.getDefault();

   // start separate thread
   Thread separateThread = new Thread(new Runnable() {
      public void run(){

         if (display.isDisposed()) return;
         final Object execObj = listener.execute();

         if (display.isDisposed()) return;
         display.syncExec(new Runnable() {
            public void run(){
               // sync back to main swt thread
               if (listener.isDisposed())
                  return;
               listener.update(execObj);
            }
         });
         done = true;

         if (display.isDisposed()) return;
         display.wake();
      }
   });
   separateThread.start();

   while (!done && !composite.isDisposed()) {
      if (!display.readAndDispatch())
         display.sleep();
   }
}