[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipse-dev] Eclipse beginner threading question...
|
You should only use the SWT event thread to manipulate your SWT widgets.
You can invoke a method on the event thread using either
Display.syncExec(Runnable runnable) or Display.asyncExec(Runnable
runnable) -- depending on whether you want your background thread to block.
From your MultiPageEditorPart, you should be able to do something like:
Runnable runnable = new Runnable() {
void run () {
// activities you want to perform in the event thread
}
};
getSite().getShell().getDisplay().asyncExec(runnable);
Hope that gets you unstuck.
- Russ
Horst Heistermann wrote:
Hi,
I am new to eclipse and I am having a problem with threads. I have
created a MultiPageEditorPart
editor. I have a background thread listening to model changes in my
application. I am notified of these changes
in a non -gui thread. I want to set MultiPageEditorPart as dirty
whenever I receive a model change event.
So I wrote a function like this
public void setEditorModified() {
m_bModified = true;
if (!super.isDirty()) {
firePropertyChange(IEditorPart.PROP_DIRTY);
}
}
This method crashes whenever I call it from the background thread.
Below is the error stack. But it is a bit misleading. From the
debugger, I can see the issue is with the thread I am calling
firePropertyChange() from. Can anyone tell me what is the proper way
to update the dirty state from a background thread. Also, the
background thread is not aware of the GUI components it only has a refer.