Hi. I have this problem with a Windows Form Application. I'm working with the Client, the server is already working and tested.
If you look at this code:

 void WaitForMessage()

    bool dropserver = false;

    while(dropserver == false)

        char inputmessage[250];     

        int bytes = recv(sConnect, inputmessage, sizeof(inputmessage), 0);
        if(bytes <= 0)
            dropserver = true;

            rtbLog->AppendText("Wait for message");

            /*String^ tempmessage = System::Runtime::InteropServices::Marshal::PtrToStringAnsi (IntPtr(inputmessage));*/

            for(int i = 0; i < MaxLength; i++)



This function is used to recover messages from the server and put it on the log called rtbLog. (RichTextBox) The function thread is started from another function (main thread ofc). Here:

   Form1 ^ f1 = gcnew Form1;
    ThreadStart^ threadDelegate = gcnew ThreadStart(f1, &Form1::WaitForMessage);
    Thread^ newThread = gcnew Thread(threadDelegate);

Now to the problem. The AppendText method is not working. rtbLog->AppendText(system string); I have tried in many ways and searched on the internet. The only thing i find is something with a Invoke() method? When i debugg the WaitForMessage function it is working and the richtextbox is getting it. But when i test it nothing is popping up on the richtextbox. This is ofcourse messegaes from the server. If i text the richtextbox with rtbLog->AppendText(just some trash data); from another function it works, but not from WaitForMessage. It's because its on a new thread? Or something like that. Would realy like to get some help.

6 Years
Discussion Span
Last Post by thines01

Is it the actual WaitForMessage that's not being called?
Have you tried creating a temp file inside your function just to see if it is being called (but the location it's trying to put it is failing)?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.