|
Re: UI Thread question [message #466187 is a reply to message #466185] |
Wed, 04 January 2006 18:28 |
Eclipse User |
|
|
|
Originally posted by: ingo.siebertNOSPAM.cas.de
Hi,
i'm trying to help but i'm also a beginner.
Both sync and async work on the UI thread.
Sync halts the execution on the current thread and asynch doens't halt
the current thread.
For a new thread, use the normal Java classes. If you need to call
methods from the UI thread, than choose sync or async.
Ingo
Aleksandr Kravets schrieb:
> Hi,
>
> I have an application that does database lookup and might take some time
> to process the request. I tried to put the call to the database in a
> thread, but screen still locks up. What am I doing wrong?
>
> buttonOK.addListener(SWT.Selection, new Listener() {
> public void handleEvent(Event event) {
> Display _display = Display.getCurrent();
> _display.asyncExec (new Runnable () {
> public void run () {
> sRun = sRun.buildGUI(value,
> clientName.toLowerCase());
> if(sRun.isDataExists()){
> shell.dispose();
> }
> }
> });
> }
> });
>
> And couple of questions:
>
> 1. What is the difference between asyncExec and syncExec
> 2. Good tutorial on SWT Threading.
>
> thanks,
> Alex
|
|
|
Re: UI Thread question [message #466220 is a reply to message #466187] |
Thu, 05 January 2006 00:02 |
Lorenz Maierhofer Messages: 88 Registered: July 2009 |
Member |
|
|
Hi,
It's exactly as Ingo described:
asyncExec still makes your code run in the UI thread - and so during the
time it takes to execute it, your UI will be blocked.
As a rule of thumb, never do someting expensive in UI thread or in
async/syncExec. The better way is to write a real thread and update the
UI via async/syncExec.
About Threading:
Check out the Job API that eclipse provides (google will help you).
For standard Java threads, check out the Thread class.
Lorenz
Ingo Siebert wrote:
> Hi,
>
> i'm trying to help but i'm also a beginner.
>
> Both sync and async work on the UI thread.
> Sync halts the execution on the current thread and asynch doens't halt
> the current thread.
>
> For a new thread, use the normal Java classes. If you need to call
> methods from the UI thread, than choose sync or async.
>
> Ingo
>
> Aleksandr Kravets schrieb:
>> Hi,
>>
>> I have an application that does database lookup and might take some
>> time to process the request. I tried to put the call to the database
>> in a thread, but screen still locks up. What am I doing wrong?
>>
>> buttonOK.addListener(SWT.Selection, new Listener() {
>> public void handleEvent(Event event) {
>> Display _display = Display.getCurrent();
>> _display.asyncExec (new Runnable () {
>> public void run () {
>> sRun = sRun.buildGUI(value,
>> clientName.toLowerCase());
>> if(sRun.isDataExists()){
>> shell.dispose();
>> }
>> }
>> });
>> }
>> });
>>
>> And couple of questions:
>>
>> 1. What is the difference between asyncExec and syncExec
>> 2. Good tutorial on SWT Threading.
>>
>> thanks,
>> Alex
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03644 seconds