Issue
I'm developing a plugin for my own projects (Eclipse foundation, using SWT), but I'm faced with the following problem. The plugin does a lot of work when the execution starts, so it can take 2 or 3 minutes to finish the whole operation. I decided to implement a log window so I can check out the progress and any error it may happen. So while it does his job, the window/frame is filled with all the info when the whole operation is finished. Naturally I figured that since its using a single thread to do everything, the "refresh interface" event is triggered once the thread ends the operation.
Is there any proper or "correct" way to solve this problem? I'm accostumed to web application development, and I have very little knowledge of SWT in general. I have an idea of using different threads to handle the different operations, synchronizing them when its needed, but I'm not completely sure if that would work or if there is a better approach within the boundaries of standalone apps.
Thanks for any tip or hint!
Solution
So at the end I followed the suggestions, I generated a custom Job that uses the Display.getDefault().asyncExec() operation. A small sample like this worked:
Job synJob = Job.create("Synchronize Files", (ICoreRunnable) monitor -> {
for(String filePath : paths) {
//my operation that sync some files in workspace in a loop ...
//...
//now log some data, updating the UI
Display.getDefault().asyncExec(() -> {
//generates a text and appends it to a frame etc.
Label label = new Label(myFrame, 0);
//etc
});
}
});
synJob.schedule();
Answered By - Mauricio