Eclipse Plugin IDE frozen / not refreshing during process

100 Views Asked by At

I'm developing an Eclipse plugin right now and there's a problem I can't resolve. There's this situation:

I have two processes. Process A fills a View (with a Nebula XViewer table). Process B uses the data from the view (results in some kind of producer-consumer problem I guess).

Now, I can trigger both processes manually which works perfectly fine. But I also want to have the option to trigger process B automatically when I manually start process A (ofc after A is finished).

The problem is tho, that while the processes are running, the Plugin-Eclipse-IDE is frozen and the view does not get refreshed until the process is finished, even if I call the refresh function of the ViewPart or View. This leaves me in the situation that process B starts, but the data in the view is old and not from the last run of process A.

Does someone know how to fix that? Maybe there is some way to set a commands priority to highest? To force eclipse to refresh the view before doing something else?

1

There are 1 best solutions below

0
On BEST ANSWER

From the sound of your question you have code which takes a long time to run executing in the User Interface thread. This is guaranteed to cause the UI to freeze as the UI thread must be kept responsive. Long running code should be run in the background using an Eclipse Job or a Thread.

When you are running code in the background you cannot update the UI directly. Instead you will have to use the asyncExec or syncExec methods of Display to update the UI.