SWT Threads


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: SWT Threads

  1. #1
    Join Date
    Jul 2005
    Posts
    1

    SWT Threads

    I am having problems with SWT threads. I have a method that takes long to complete and if its in the event handler it freezes the GUI.

    I changed the code so that the event handler runs a thread. I can get the thread to make changes to the GUI. I can get the thread to perform set changes to the GUI. But I cant create a thread that gets info from the GUI. i.e I have a form with many text boxes that facilitate user input. The input must be used when the user presses a button. i.e The user inputs a username and password and then presses the submit button. If I try txtPassword.getText() in my thread then I get this error:

    Exception in thread "Thread-0" org.eclipse.swt.SWTException: Invalid thread access

    If I hard code the user name and password in my code then it runs perfectly

    Please supply me with some simple code snippets of how to get the threads working. A basic way of setting values and a basic way of reading values.

    Thanks
    Greg

  2. #2
    Join Date
    Dec 2003
    Location
    tx/us
    Posts
    131
    Have you tried creating a value object to hold the content of the form fields and passing that to the threaded object constructor? That would be similar to the java.lang.Thread examples in the API.

  3. #3
    Join Date
    Jul 2005
    Posts
    1
    Try the following code for update

    final String updateInfo = " put updated info";
    Runnable r = new Runnable(){
    public void run(){
    aText.setText(updateInfo);
    }
    };

    display.asyncExec(r);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center