Periodic job with UI interaction on eclipse plugin [message #987811] |
Wed, 28 November 2012 04:19  |
Eclipse User |
|
|
|
I'm developing an eclipse plugin and I'd like to have a background job that, under certain conditions, pops up a shell. The problem is that:
- asyncExec runs on the UI thread, so I can't do a while(true) ... Thread.sleep(). Same thing for UIJob
- a separate Thread (let's say a Runable, scheduled via ScheduledExecutorService.scheduleatFixedRate) solve the problem of running the job in the background, but then I have no access to the UI thread to reuse the display.
- I also tried to create a new Display ... I've got no errors, but the shell does not shows up.
Trying to reuse the display with Display.getDefault() or Display.getCurrent() hangs while creating Shell and Display.getDefault().getActiveShell() also hangs.
So, what should I do instead ?
Any help is more than welcome!
|
|
|
Re: Periodic job with UI interaction on eclipse plugin [message #988337 is a reply to message #987811] |
Thu, 29 November 2012 08:18  |
Eclipse User |
|
|
|
Never create your own Display unless know otherwise!
Use a background thread to do your work and use Display.syncExec() with your current display to do your UI operations as required. If you're building on top of the Eclipse Platform, and not just on SWT, the Jobs API is a great way -- just subclass from the Job class rather than the UIJob class.
Brian,
|
|
|
Powered by
FUDForum. Page generated in 0.08410 seconds