CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010
    Posts
    7

    Question TcpClient in Managed C++

    Hey guys,

    When I run this managed code snippet:
    listener = gcnew TcpListener(MyIPAddress, ServerPort);
    listener->Start();
    MyTcpClient^ mclient; //TcpClient public
    TcpClient^ aux = listener->AcceptTcpClient();
    mclient = static_cast<MyTcpClient^>(aux);

    I get the following error:
    "System error: cross-thread operation not valid: Control 'listBox1' accessed from a thread other the thread it was created on."
    Please, I just can´t understand what´s going on!

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: TcpClient in Managed C++

    This really looks interesting, because your code fragment doesn't contain listBox1.
    Generally, cross-thread operations on Windows Forms controls are not allowed, they should be serialized using Control.BeginInvoke and Control.Invoke methods.

  3. #3
    Join Date
    Aug 2010
    Posts
    51

    Smile Re: TcpClient in Managed C++

    hi,


    cross-thread operations on Windows Forms controls are not allowed, they should be serialized using Control.BeginInvoke and Control.Invoke methods.


    regards,
    phe9oxis,
    http://www.guidebuddha.com

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