K
Ken Brannigan
Hello,
I have a Class Library that contains a windows form and a public class. The
public class has a static method that creates a windows form and uses some
of its functionality. I need the statis method to pause while the form does
its processing. When the form is done the code in the static method will
finish and return control to the user. I can not display it modally because
this is not allowed when a DLL is being used by say ASP.NET. I have tried
using a seperate thread but after the Form.Show executes the method finishes
and hence the thread dies before the form does its work. I have also tried
using the AutoResetEvent class but when the WaitOne method is called
everything just freezes since it is all on the same thread. I am currently
doing a tight loop with alow of Application.DoEvents and constantly checking
to see if form is finished. I HATE DOING IT THAT WAY!! There must be a way I
can do this!! Please any help would be greatly appreciated!!!
Sample:
public static void RunForm()
{
Main mainForm = null;
mainForm = new Main();
mainForm.Left = 100;
mainForm.Show();
//WAIT UNTIL FORM FINISHES PROCESSING.
mainForm.Close();
mainForm.Dispose;
mainForm = null;
}
Thank you for any help!!!
Ken
I have a Class Library that contains a windows form and a public class. The
public class has a static method that creates a windows form and uses some
of its functionality. I need the statis method to pause while the form does
its processing. When the form is done the code in the static method will
finish and return control to the user. I can not display it modally because
this is not allowed when a DLL is being used by say ASP.NET. I have tried
using a seperate thread but after the Form.Show executes the method finishes
and hence the thread dies before the form does its work. I have also tried
using the AutoResetEvent class but when the WaitOne method is called
everything just freezes since it is all on the same thread. I am currently
doing a tight loop with alow of Application.DoEvents and constantly checking
to see if form is finished. I HATE DOING IT THAT WAY!! There must be a way I
can do this!! Please any help would be greatly appreciated!!!
Sample:
public static void RunForm()
{
Main mainForm = null;
mainForm = new Main();
mainForm.Left = 100;
mainForm.Show();
//WAIT UNTIL FORM FINISHES PROCESSING.
mainForm.Close();
mainForm.Dispose;
mainForm = null;
}
Thank you for any help!!!
Ken