View refresh problem [message #448941] |
Sat, 15 January 2005 14:50 |
Eclipse User |
|
|
|
Originally posted by: dicesCAVA.ctonet.it
If i refresh my view from new Thread throw this exception:
org.eclipse.swt.SWTException: Invalid thread access
code is this:
public void myMethod(){
new Thread(){
textViewer.getDocument().set(veryHeavyMethod()); //veryHeavyMethod
return a string
textViewer.refresh();
}.start();
}
why this exception?
--
(Sorry for my spaghetti english)
|
|
|
Re: View refresh problem [message #448946 is a reply to message #448941] |
Sat, 15 January 2005 20:43 |
Eclipse User |
|
|
|
Originally posted by: nickthat.yahoo.com
The problem is that you are only allowed to make certain GUI calls on the
main thread. If you have an operation that takes a long time, you can have
it run on the main thread as a sort of thread i.e. when there are no
messages being processed. This is done by using the method call.
Display.getCurrent().asyncExec(myThread)
SaThot wrote:
> If i refresh my view from new Thread throw this exception:
> org.eclipse.swt.SWTException: Invalid thread access
> code is this:
> public void myMethod(){
> new Thread(){
> textViewer.getDocument().set(veryHeavyMethod()); //veryHeavyMethod
> return a string
> textViewer.refresh();
> }.start();
> }
> why this exception?
|
|
|
Re: View refresh problem [message #448950 is a reply to message #448946] |
Sun, 16 January 2005 12:55 |
Eclipse User |
|
|
|
Originally posted by: dicesCAVA.ctonet.it
On Sat, 15 Jan 2005 20:43:39 +0000 (UTC), Nick Thatcher
<nickthat@yahoo.com> wrote:
> The problem is that you are only allowed to make certain GUI calls on
> the main thread. If you have an operation that takes a long time, you
> can have it run on the main thread as a sort of thread i.e. when there
> are no messages being processed. This is done by using the method call.
>
> Display.getCurrent().asyncExec(myThread)
Ok, it working but gui is freezed too
--
(Sorry for my spaghetti english)
|
|
|
|
Re: View refresh problem [message #448989 is a reply to message #448964] |
Mon, 17 January 2005 12:15 |
Eclipse User |
|
|
|
Originally posted by: dicesCAVA.ctonet.it
On Mon, 17 Jan 2005 08:57:07 +0100, Stefan Pietsch <pietsch@multichart.de>
wrote:
> Hi,
>
> you have to call veryHeavyMethod() in a separat thread and store the
> result
> in a string. Then this thread calls another thread with
> Display.getCurrent().asyncExec(). The second thread calls
> textViewer.getDocument().set() with the stored string.
>
> public void myMethod(){
> new Thread(){
> final String s = veryHeavyMethod();
> Display.getCurrent().asyncExec(new Runnable() {
> public void run() {
> textViewer.getDocument().set(s);
> textViewer.refresh();
> }
> });
> }.start();
> }
if do that Display.getCurrent return null.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02842 seconds