Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Disabling IAction from non-UI thread.
Disabling IAction from non-UI thread. [message #1242995] Mon, 10 February 2014 11:13 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi all,

Some part of my code that updates UI runs in ExecutorService, i.e:

...
ExecutorService executor = new ThreadPoolExecutor(1, 1, 1000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(1000));

Runnable task = new Runnable()
{
	@Override
	public void run()
	{
		IAction action = ...
		action.setEnable(false);		
	}
}

executor.execute(task);
...


The code above throws IllegalStateException since it's not running in UI thread but to do so I have to obtain instance of Display using Display.getCurrent() or Display.getDefault() which keeps returning null.

Any ideas ?

Any help would be greatly appreciated.

Thanks & Regards,

Setya
Re: Disabling IAction from non-UI thread. [message #1243057 is a reply to message #1242995] Mon, 10 February 2014 13:08 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Setya,

there are many users in parallel, and so there are many displays. Code
that's running in a non-UI thread is not bound to any particular
display, so Display.getCurrent() will return null. You have to memorize
the display that you want to access from a background thread.

Regards,
Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Installation of dropdown2.2 (incubation) fails
Next Topic:Web Workers in RAP
Goto Forum:
  


Current Time: Fri Apr 26 07:38:42 GMT 2024

Powered by FUDForum. Page generated in 0.03105 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top