Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Why doesn't Job show the progress dialog?
icon5.gif  Why doesn't Job show the progress dialog? [message #632298] Tue, 12 October 2010 13:39 Go to next message
Alexandra Niculai is currently offline Alexandra NiculaiFriend
Messages: 84
Registered: July 2009
Member
Hi

I've been struggling with this for some time.
I want to use jobs for my long actions.
I read in the documentation and in a lot of examples that running a job should show a progress dialog with an option to run in the background. Also, the job would not block the interface.
In my case, none of these happen.
If I try to run a job with only a sleep action inside, I get the progress dialog and my app remains responsive.
But as soon as I replace the sleep with a real method, the progress dialog doesn't show at all(or it shows for 0.25 seconds at the end, even if the job does take quite some time) and the UI isn't responsive anymore.
Here's also a snippet:
	Job job = new Job("Cancelling edition") {

			@Override
			public IStatus run(IProgressMonitor monitor) {
				monitor.beginTask("Cancelling edition...",
						IProgressMonitor.UNKNOWN);
				IStatus status = Status.OK_STATUS;

				try {
						protocol.cancelEdition();					
				} catch (Exception e) {
					status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "",
							e);
					Status failStatus = new Status(IStatus.ERROR,
							Activator.PLUGIN_ID, "", e);
					StatusManager.getManager().handle(failStatus,
							StatusManager.LOG);
				} finally {
					monitor.done();
				}
				return status;
			}
		};
		job.setUser(true);
		job.schedule();


I also noticed that the application remains responsive if I don't set the job as user job.
Please help!
Thank you!

Alexandra.

[Updated on: Thu, 14 October 2010 09:07]

Report message to a moderator

Re: Why doesn't Job show the progress dialog? [message #634143 is a reply to message #632298] Wed, 20 October 2010 15:53 Go to previous messageGo to next message
Federico Gaule is currently offline Federico GauleFriend
Messages: 21
Registered: September 2010
Location: Buenos Aires, Argentina
Junior Member
Hi Alexandra.

Quick question. Does your "real" method contains a call to Display.asynch / synch ? Cause you code seem to be OK.
setUser method can be false, and should not freeze your UI. When you set it to true, it only make a dialog with the job progress to be popped up.

Regards
Re: Why doesn't Job show the progress dialog? [message #634193 is a reply to message #634143] Wed, 20 October 2010 18:31 Go to previous messageGo to next message
Alexandra Niculai is currently offline Alexandra NiculaiFriend
Messages: 84
Registered: July 2009
Member
Hi Federico,
Thank you for answering.
No, the method in the job only calls a server that does some non-ui operations.
This is why I can't understand the behavior of my app.

Greetings
Alexandra.
Re: Why doesn't Job show the progress dialog? [message #634199 is a reply to message #634193] Wed, 20 October 2010 18:46 Go to previous messageGo to next message
Federico Gaule is currently offline Federico GauleFriend
Messages: 21
Registered: September 2010
Location: Buenos Aires, Argentina
Junior Member
Hi,

If you are calling a server method that returns quickly cause it do its work in a thread for example, you will be calling monitor.done() closing the progress monitor.

Have you checked that?

Regards
Re: Why doesn't Job show the progress dialog? [message #634220 is a reply to message #634199] Wed, 20 October 2010 19:45 Go to previous messageGo to next message
Alexandra Niculai is currently offline Alexandra NiculaiFriend
Messages: 84
Registered: July 2009
Member
Good point, I didn't check that, I have to ask tomorrow at work.
But it's a heavy method, that's why I thought that putting it a job would make it easy on the interface. If I don't put it in the job, it just freezes the interface for a few long seconds.
If it would just return fast, that would explain the fact that the progress dialog doesn't show. But why would the rcp freeze?
Re: Why doesn't Job show the progress dialog? [message #634221 is a reply to message #634220] Wed, 20 October 2010 19:53 Go to previous messageGo to next message
Federico Gaule is currently offline Federico GauleFriend
Messages: 21
Registered: September 2010
Location: Buenos Aires, Argentina
Junior Member
When the UI freezes is because there is something huge running in its thread, avoiding app to refresh its widgets. Taking into account that, i would think your sever method is blocking, which would dump my last comment.
Tomorrow debug a bit more and tell me what happens.
Re: Why doesn't Job show the progress dialog? [message #634616 is a reply to message #634221] Fri, 22 October 2010 12:54 Go to previous messageGo to next message
Alexandra Niculai is currently offline Alexandra NiculaiFriend
Messages: 84
Registered: July 2009
Member
Hi,

Asked my colleague about the function and it's not returning until it's done.
This function is actually called on a CORBA object.
If I call anything that's not on the server, the interface reacts as expected.
Could this be the reason for the strange behavior of the interface?

If I run a debug with breakpoint exactly on that method, the progress dialog appears and the interface doesn't freeze, so debugging doesn't seem to help much now.
So I added a
Thread.sleep(1000);
before the method and the progress dialog appeared, but the interface still freezes if I try to click on something while the job is being executed.
The dialog doesn't show if I put the Thread to sleep for less then 1000 millis.

Alexandra.

[Updated on: Fri, 22 October 2010 13:06]

Report message to a moderator

Re: Why doesn't Job show the progress dialog? [message #634624 is a reply to message #634616] Fri, 22 October 2010 13:13 Go to previous message
Federico Gaule is currently offline Federico GauleFriend
Messages: 21
Registered: September 2010
Location: Buenos Aires, Argentina
Junior Member
Hi.
There shouldn`t be any problem calling any method outside your server. If your method returs quickly, obviously, the popup won't show up, or it will for a few seconds. When you are adding Thread.sleep(xxx) you are making it long more time.
But in both cases, it shouldn't freeze you UI.
Previous Topic:Get Content of Popup menu
Next Topic:Import/Export Feature
Goto Forum:
  


Current Time: Thu Mar 28 23:07:41 GMT 2024

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

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

Back to the top