Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » UI freezes when running a long operation in a jface wizard
UI freezes when running a long operation in a jface wizard [message #1778074] Sat, 09 December 2017 07:46 Go to next message
Ali Sedaghat is currently offline Ali SedaghatFriend
Messages: 17
Registered: April 2015
Junior Member
I have a UI update operation that may take several seconds to complete. I've used progress monitor to prevent ui freeze as follows:

getContainer().run(true, false, new IRunnableWithProgress() {

					public void run(IProgressMonitor arg0) throws InvocationTargetException, InterruptedException {
						arg0.beginTask("", IProgressMonitor.UNKNOWN);
					//some code
Display.getDefault().asyncExec(new Runnable() {

							public void run() {
//ui update opeation

However, the UI still freezes while executing the ui update operation. Any advice would be appreciated.

[Updated on: Sat, 09 December 2017 08:09]

Report message to a moderator

Re: UI freezes when running a long operation in a jface wizard [message #1778094 is a reply to message #1778074] Sun, 10 December 2017 03:12 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

Your `getContainer().run(true, ..., IRunnableWithProgress)` causes your runnable to be forked off to another thread. But your Runnable then does a `Display#asyncExec()` which causes your UI update to happen on the SWT thread. You're effectively executing your UI update operation directly.

You have two options:

1. Wrap your UI update operation with `BusyIndicator#showWhile()` to show the busy cursor: it at least indicates to the user that some long-running operation is in progress.

2. Periodically dispatch any pending SWT events during your UI update operation (e.g., by calling `Display#readAndDispatch()`). This will cause your UI to seem live.

3. Break up your UI operation into non-UI work and UI work, and run the non-UI work via `getContainer().run()`.
Previous Topic:[SOLVED] RTL support for Wizards or TreeViewers?
Next Topic:Scrolling JFace viewers on a white background (Linux/GTK)
Goto Forum:

Current Time: Sun Apr 11 19:58:07 GMT 2021

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

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

Back to the top