-
May 9th, 2007, 02:54 PM
#1
I Urgently Need Help About Threading !
I'm writing a programme for my final project which I have to finish in two days . This programme includes a TCPListener to get some data over TCP/IP protocols. So I've made a second thread for this TCPListener. Otherwise, other components woudn't work at the same time due to infinite loop as u predict. But, now I have an other problem; When I start my thread as I wrote below;
Form1^ s = gcnew Form1();
ThreadStart^ serverDelegate = gcnew ThreadStart(s,&MyMessenger::Form1::ServerActivate);
Thread^ serverThread = gcnew Thread(serverDelegate);
serverThread->Start();
ServerActivate function (which includes TCPListener) works correctly, can call other functions, but while this thread is working I can not control the properties of components of Form1, such as textbox->text. I've tried many things, but I couldn't. Please help me, how can I solve this problem?
-
May 14th, 2007, 03:58 PM
#2
Re: I Urgently Need Help About Threading !
You can not modify the the form from a thread other than the one that it was created on. You need to call the BeginInvoke method coupled with the InvokeRequired property in order to modify UI controls.
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
|