CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2006

    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);

    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?

  2. #2
    Join Date
    Apr 2007

    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

Click Here to Expand Forum to Full Width