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

    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?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,492

    Re: I Urgently Need Help About Threading !

    Two questions:

    1. Are you waiting for this thread to finish in the UI thread?
    2. Can you post the code for the thread? I ask because if the thread is in a tight loop, it may starve the UI thread from cpu time.

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

Featured