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
07-08-2005, 11:39 PM
ray326
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.
07-13-2005, 02:44 AM
orbanana
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);