Skip to main content
rephrased title to include the critical component of the questions - a Windows Forms control
Link

Thread problem withupdating Windows Forms control in XNA C#

edited tags
Link
user1430
user1430
Source Link
Luis
  • 303
  • 1
  • 3
  • 8

Thread problem with XNA C#

I'm development a network card game, and for now i've two players connected but there is a problem with one of them, this one can't do anything on the game. Looks that screen was blocked. I'm think that is because a code i used before.

That code is:

if (InvokeRequired)
            {
                this.Invoke(new MethodInvoker(delegate
                {

                   ...

            }));
                return;
            }

The code above is surrounding code to changing Button values, make connection with server and create game window. Without this code a warning is shown.

InvalidOperationException was unhandled

Cross-thread operation not valid: Control 'startGameButton' accessed from a thread other than the thread it was created on.