i have problem in updating GUI from another thread
my code gives me exception
i debugged to find the reason of exception

i found that it is here
[ this part of Wedget class

if (display.thread != Thread.currentThread ()) {

if (display.threadId != OS.GetCurrentThreadId ()) {

thanks in advance

Edited by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

8 Years
Discussion Span
Last Post by A M R

You can only make updates to SWT controls from within the SWT UI thread. You need to use either synExec or asyncExec to accomplish running other code that updates SWT controls because these methods cause the code to be run on the SWT UI thread. See :


P.S. you should be saying display.getThread() not display.thread and Thread.currentThread() not OS.getCurrentThread or whatever you are calling. .

Edited by BestJewSinceJC: n/a


thanks a lot sir
is there any other method to do that

my application may do a lot of updates in 1 second so a lot of threads
so bad cpu usage


No, there is no other method to do that. It isn't bad cpu usage. What is your reasoning behind thinking it is bad cpu usage?


my application receives data frames from bus
so if i send a a lot of frames the CPU usage reaches 55%
because of creating new thread for every data received
it is my problem with this method of updating


The methods I described to you are only for updating UI elements. Not for executing long running tasks. Executing long running tasks on the UI thread (i.e. by calling asynchExec on your code block) is going to freeze up the UI, making it unresponsive to the user.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.