The UI Thread in ACTF Documents

Included in the org.eclipse.actf.model.IGuiModel interface are three methods regarding the UI thread and execution upon this thread. This distinction of the UI thread is important for two reasons. First, many GUI-based applications wish to completely separate the GUI presentation and view from the control and program logic of updating and populating data structures that support the GUI model. Doing so prevents poor GUI presentation due to flicker or timely programmatic operations. Second, some GUI frameworks, like Eclipse SWT, require that all GUI-related tasks (e.g., component instantiation, drawing, event-handling, and even accessing properties of components) are to occur on the UI thread. Attempting to create or invoke methods upon GUI controls from any thread that is not the UI thread causes an error in SWT.

The invokeOnUIThread(Runnable) method runs the task implemented by the given Runnable until completion, causing the calling thread to wait until the task is complete. This method should be invoked for any operation involving a GUI component, whether this be drawing the component, updating its items, or retrieving its properties. The ACTF engine always uses this method to perform GUI-related functions and any implementations of ACTF interfaces should do the same to prevent runtime problems.

The same effect can be achieved by invoking the syncEval function. This function takes three parameters:

  1. The code to be executed on the UI thread.
  2. The global environment hashtable (which can be retrieved using the globals() built-in function).
  3. The local environment hashtable (which can be retrieved with the locals() built-in function).

Simply place the code to be executed on the UI thread in quotes and call syncEval("<code>", globals(), locals()). (At this time, there is no way to perform such a call in other scripting languages.)