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

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

            for(int i = 0; i < MaxLength; i++)
            {
            rtbLog->AppendText(Char::ToString(inputmessage[i]));
            }


            /*this->rtbLog->AppendText("\n");*/
        }
    }

    }

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);
    newThread->Start();

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.