[Solved] Thread error in C# Windows Form


You get the Cross-thread error when you try to update a UI element from any thread it was not created on.

Controls in Windows Forms are bound to a specific thread and are not thread safe. Therefore, if you are calling a control’s method from a different thread, you must use one of the control’s invoke methods to marshal the call to the proper thread. This property can be used to determine if you must call an invoke method, which can be useful if you do not know what thread owns a control.

Refer here for more

Try this .This works fine for me

   if (pictureBoxname.InvokeRequired)
                    pictureBoxname.Invoke(new MethodInvoker(delegate
                    {
          //access picturebox here
                    }));
                else
        {

  //access picturebox here
}   

5

solved Thread error in C# Windows Form