I have a panel that contains a active x component to show a camera stream. this is external code. this panel can only be run a STA thread becouse of the camera driver.
how can i show this panel on a form created on another thread? for example:
[STAThread]
public Main()
{
Panel display = new Panel();
Thread form = new Thread(()=>
{
Form displayForm = new Form();
displayForm.Show();
displayForm.Controls.Add(display);
});
form.Start();
CameraComponent axCamera = new CameraComponent(); //create new camera component active x component
display.Controls.Add(axCamera);
}
But this throws an exception on : display.Controls.Add(axCamera);
exception: Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.