Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] in a sub thread, how to call a widget of its father


The example cited in the online documentation should add a test:

   // do time-intensive computations
  ...
  // now update the UI. We don't depend on the result,
  // so use async.
  display.asyncExec (new Runnable () {
     public void run () {

        if (myWindow.isDisposed())  // check if still around
          return;
        myWindow.redraw ();
     }
  });
  // now do more computations


In some products, I've noticed .log files littered with exceptions because the asyncExec is processed after the window has already closed.  It wouldn't be a bad idea to integrate this check into the SWT API, e.g.:

    myWindow.asyncUpdate(new Runnable...);

This in turn would check if the widget still exists before executing the runnable.

-- Dan



----- Message from "Hélène ORTIZ" <hchagnot@xxxxxxxxxxxxxxx> on Thu, 21 Oct 2004 10:37:02 +0200 (CEST) -----
To:
<platform-swt-dev@xxxxxxxxxxx>
Subject:
Re: [platform-swt-dev] in a sub thread, how to call a widget of its father

Tina,

For a code sample, have a look here :

http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/swt_threading.htm

> Hi
>   So, may I use event and listener to inform the UI Thread to modify
> its widget such as Label.
>   If it can, could you please provide a slip of code !
> Regard
> -Tina
>


Back to the top