|
-
Aug 21st, 2006, 09:07 AM
#1
Thread Starter
Hyperactive Member
[2.0] Thread trouble
Hi. Im making a small socket app (im talking about the server by the way). All it does is wait for a connection, and when it recieves one, it displays a message from the client closes the connection, and then loops to wait for a new connection.
I wanted to be able to have a button to stop the server at any time, but because the UI isnt responsive while waiting for a connection or in a loop, so i put the method into a thread, but the it uses textboxes that were created in another thread, so i cant do it that way.
I apoligise if that wasnt clear.
Can anyone help?
-
Aug 21st, 2006, 09:11 AM
#2
Re: [2.0] Thread trouble
You can do it that way. You can use a BackgroundWorker and call its ReportProgress method to raise the ProgressChanged event in the UI thread. You can then access any control directly from the ProgressChanged event handler. If you just want to mange the worker thread yourself then you simply use delegation to invoke a method on the UI thread from which you can then access your controls. Search the forum for my user name and the keyword "invokerequired" and you'll find an example.
-
Aug 21st, 2006, 09:22 AM
#3
Thread Starter
Hyperactive Member
Re: [2.0] Thread trouble
Im sorry but I'm not sure I understand.
-
Aug 21st, 2006, 09:40 AM
#4
Re: [2.0] Thread trouble
Have you done the search and read the code? Have you read about the BackgroundWorker class?
-
Aug 21st, 2006, 09:58 AM
#5
Re: [2.0] Thread trouble
What if you simply pass the textbox values as the threading method's arguments?
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
|
Click Here to Expand Forum to Full Width
|