Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Thead in SWT !

Everything that is done in the Runnable is executed in the UI thread and 
blocks the UI from processing events until it is finished.  The idea is 
that you do all your work (such as querying a database) in a thread that 
you have created and when you want to update the UI, you use 
Display.syncExec to do only the updating of the UI (e.g. Text.setText()). 
This will solve both of the problems you described below.  You should 
probably use Display.syncExec rather than Dispaly.asyncExec.  The syncExec 
is executed before the call returns and the asyncExec is executed some 
time in the future -  after the call to Display.asyncExec has returned.

For an example of the correct use of Display.syncExec see:

 
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet7.java?rev=HEAD&content-type=text/vnd.viewcvs-markup

For a description of the SWT threading mechanism see:

 
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/faq.html#uithread




bbskill <bbkills@xxxxxxx> 
Sent by: platform-swt-dev-admin@xxxxxxxxxxx
11/26/2004 08:22 AM
Please respond to
platform-swt-dev


To
platform-swt-dev@xxxxxxxxxxx
cc

Subject
[platform-swt-dev] Thead in SWT !






hello ,anynoe.
I have two problems.
I use this code :

   display.asyncExec (new Runnable () {
      public void run () {               //  do some I/O operation.
      }
   });

first problem :
I found when this Thread start , the main interface dosen't react to the
window operations
such as resize the window or click any buttons until the run() function
return !
what is wrong with the asyncExec(new Runnable()) ?

second problem :
I appends some strings to the Text of the Shell in the run() function ,
but the Strings
dosen't appear on the Text of the Shell until the run() function return
! I want once I append
a string to the Text , The String should be appear on the Text at once !
this is my code to append string to the Text :
text.append(str);
text.getShell().layout();
but it dosen't help !
what should I do ?
Thank you for any help !!
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev




Back to the top