yoshitaka - 2009-01-13

Hi Vincent,

If I understand your question correctly, this is a generic issue regarding the usage of Display#asyncExec(). You can see the same behavior (i.e. IDE freeze) with the following code without using SWTChart.

public class SampleView extends ViewPart {

@Override
public void createPartControl(Composite parent) {
parent.getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
while (true) {
// do nothing
}
}
});
}

@Override
public void setFocus() {
// do nothing
}
}

Since UI-thread is blocked by run() method above, IDE doesn't have a chance to update itself.

1) It is not good idea to use Display#asyncExec() for the operation which may take long time like manipulating model. The asyncExec() should be used only for the operation redrawing/updating widgets like Control#update(), and the run() should return asap.

2) Instead of repeating something within run() for long time, it would be better to invoke asyncExec() multiple times for short time.

3) In the case of repeating the UI updates so frequently, all of UI updates would be not always necessary. You could use org.eclipse.core.runtime.jobs.Job to schedule the job to update and cancel the already scheduled same job.

I hope this answers your question.

Best Regards,
Yoshitaka