Keep WinForm open on own thread

  • Thread starter Thread starter George Rice
  • Start date Start date
G

George Rice

Hi,

I have a situation where I have a sub that is started on its own thread. The
sub opens a form which is supposed to stay open, and it does open for a
brief flash, but as soon as the sub ends, the form goes away.

This behavior makes sense to me, but I'm wondering how I can keep the form
open until the user is done filling it in, then close the form and abort the
thread.

Thanks in advance,

-George
 
Are you calling Application.Run to run your form?

private void button1_Click(object sender, System.EventArgs e)
{
Thread thread = new Thread(new ThreadStart(LauchNewThread));
thread.IsBackground = true;
thread.Start();
}

private void LauchNewThread()
{
Form1 f = new Form1();
Application.Run(f);
}

=================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools
 
Back
Top