-
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
-
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.
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks