I have strange problem.
I have 3 forms. form1, form2, form3.
form1 is starting/main form. in form1 I have code:
form2 f2 = new form2;
f2.ShowDialog();
form2 opens, I can't focus on foorm1, they are both on the same thread. Just what I want.
On form2 I have code:
form3 f3 = new form3;
DialogResult result = f3.ShowDialog();
I run this code and... For some, unknown for me reason this form3 runs on new thread and I can focus on form2. I don't want this to happen. I have no idea why this form3 runs on new thread. I can't use DialogResult because it leads to error (Cross-thread).
It behaves as if I was using f3.Show() but I'm using f3.ShowDialog();
Than you in advance.
P.S.
If i use
form3 f3 = new form3;
DialogResult result = f3.ShowDialog(this);
I got this:
System.InvalidOperationException was unhandled by user code
Message=Cross-thread operation not valid: Control 'form2' accessed from a thread other than the thread it was created on.
on this line:
DialogResult result = f3.ShowDialog(this);