Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Executing code from a non-UI thread and then UI thread
Executing code from a non-UI thread and then UI thread [message #238599] Fri, 21 September 2007 16:39 Go to next message
Eclipse UserFriend
Originally posted by: malnatij.lu.unisi.ch

Hi, I have some intensive task that basically computes and fills in a set of data structures.
After setting the data up, I need to show a graphical representation in my plug-in view.

The ModelExtractor extends Job and performs the intensive task.

projectScanner = new ModelExtractor(wantedProject);
			System.out.println("ModelExtractor created");
			projectScanner.setPriority(Job.LONG);
			projectScanner.schedule();
			
			projectScanner.addJobChangeListener(new JobChangeAdapter() {
				public void done(IJobChangeEvent event) {
					if (event.getResult().isOK()){
						System.out.println("ok got");
						ViewFiller filler = new ViewFiller(projectScanner,
								view,
								systemComplexityHandler);
						Display.getCurrent().asyncExec(filler);
					}
				}});


After the ModelExtractor terminates, I need to draw the data, therefore I want to run code in the UI-Thread, using Display.getCurrent().asyncExec().
The problem is that after creating the ViewFiller class (that implements Runnable), its run method is not called by the UI-Thread.

Why?
Re: Executing code from a non-UI thread and then UI thread [message #242052 is a reply to message #238599] Sun, 30 March 2008 18:34 Go to previous message
Eclipse UserFriend
Originally posted by: malnatij.lu.unisi.ch

the problem was that Display.getCurrent() returns a null display if this method is called from a non-UI thread, therefore if you need to call it, pass the Display through the cain of calls, from a UI thread to the non-UI one.

ciao :D
Previous Topic:different model for outline view
Next Topic:draw a frame once user is over a figure
Goto Forum:
  


Current Time: Sat Apr 20 02:12:25 GMT 2024

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

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

Back to the top