S
Sunil Menon
Dear All,
I am trying to create multiple forms using thread...when one of the
external application requests for a Form my MainThread creates the
Form in a new thread...the form appears in the ForeGround if it has
been created for the first time...but subsequent creations are created
behind the application that invokes it...if I remove creation of Form
in a thread it works fine...Wot is going wrong here...
Here is the code snippet...
Thread oFormThread = new Thread(new ThreadStart(OpenFormInThread));
oFormThread.ApartmentState = ApartmentState.STA;
oFormThread.IsBackground = false;
[STAThread]
public void OpenFormInThread()
{
Form ofrm = (Form)Activator.CreateInstance(typ);
ofrm.ShowDialog();
if(ofrm != null)
ofrm.Close();
}
In the Form's Load I have written...
ShowWindow(this.Handle , SW_RESTORE);
SetForegroundWindow(this.Handle );
this.BringToFront();
But this does not seem to work...am I doing something wrong here?
Please help...
TALIA
Many Regards
Jack
I am trying to create multiple forms using thread...when one of the
external application requests for a Form my MainThread creates the
Form in a new thread...the form appears in the ForeGround if it has
been created for the first time...but subsequent creations are created
behind the application that invokes it...if I remove creation of Form
in a thread it works fine...Wot is going wrong here...
Here is the code snippet...
Thread oFormThread = new Thread(new ThreadStart(OpenFormInThread));
oFormThread.ApartmentState = ApartmentState.STA;
oFormThread.IsBackground = false;
[STAThread]
public void OpenFormInThread()
{
Form ofrm = (Form)Activator.CreateInstance(typ);
ofrm.ShowDialog();
if(ofrm != null)
ofrm.Close();
}
In the Form's Load I have written...
ShowWindow(this.Handle , SW_RESTORE);
SetForegroundWindow(this.Handle );
this.BringToFront();
But this does not seem to work...am I doing something wrong here?
Please help...
TALIA
Many Regards
Jack