Thanks Daniel for this trick and tip... I thought at something like a
synchronized(myThread){
...
}
but i didn't work of course :-(
I'll integrate the code tomorrow...
regards
Xavier
Daniel Spiewak a écrit :
...
* final* Display display = *new* Display();
Thread thread = *new* Thread(*new* Runnable() {
*public void* run() {
...
// thread code goes here
display.syncExec(*new* Runnable() {
*public void* run() {
// enter your updating code here
}
});
...
}
}).start();
...
Technically, the code within the syncExec(Runnable) block isn't
actually being run inside your other thread, It's being run inside the
event dispatch loop (i.e while(!shell.isDisposed()) if
(!display.readAndDispatch()) ...) However, this should clear up your
problem. It would be best if you can keep just the ui updating code
within the syncExec(Runnable) block and do as much as possible outside
the block in your Thread. Otherwise your ui will start to bog down.
Daniel
Xavier wrote:
Hello,
I would like to update for instance a text field in a view from a
Thread running in background. Unfortunately, this throws an error
because we try to update the field from another thread wich is not a
"graphical" thread.
Is there a simple means to do that properly?
regards
Xavier