Community articleinvokeLater method
Added by IBM contributorIBM on July 26, 2013
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

IBM® Forms Viewer only supports a single thread, but complex extensions may contain multiple threads. Use invokeLater to delay form updates from extensions until the Viewer has finished processing on the main thread.


   public static void invokeLater(Runnable theRunnable,)throws RuntimeException;


theRunnableRunnableThe thread that you want to run when the Viewer main thread is free.


Nothing if call is successful or throws an exception (RuntimeException) if an error occurs.


In the example, invokeLater is called to manage the threads in an extension. In this case, some code running in another thread needs to set a field's value. To do this, the task is contained inside a Runnable and passed to invokeLater. Furthermore, as the Runnable interface does not allow any checked exceptions to be thrown, any UWIException needs to be rethrown as a RuntimeException.
   AsyncSupport.invokeLater(new Runnable()
	    public void run()
				    theForm.setLiteralByRefEx(null, "PAGE1.FIELD7.value", 0, null, 
               null, "Updated Value");
				 catch (UWIException ex)
				    throw new RuntimeException(ex);

Parent topic:
AsyncSupport class