Possible Duplicate:
Cross-thread exception when setting WinForms.Form owner - how to do it right?
I'm newbie to C# Windows Forms Application Development.
In my application main form we create new forms in other thread like below.
Task.Factory.StartNew(
() =>
{
PlotForm plotForm = new PlotForm();
Application.Run(plotForm);
});
I want to display that forms always on top of the main form. There is a topmost property in Forms. If i set it to true they are also on top of the other forms.
In the internet it is said that solution is to set owner property and when i set this property , i got cross thread operation because forms are created different threads.
Task.Factory.StartNew(
() =>
{
PlotForm plotForm = new PlotForm();
plotForm.Owner = this;
Application.Run(plotForm);
});
Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on.
Do you know a solution?
Thanks.