I have an app where multiple child forms are spawned from a parent form, using a single child form definintion (i.e. frmParent spawns multiple instances of frmChild).
Each child runs in it's own thread - I want to be able to interact with each child independently (and I don't like MDI).
So - if the parent form is closed, how do I instruct the child forms to close themselves?
private void btn1_Click(object sender, EventArgs e)
{
Thread thread = new Thread(delegate ()
{
using (Child child = new Child())
{
child.MyName = "1";
child.ShowDialog();
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
private void btn2_Click(object sender, EventArgs e)
{
Thread thread = new Thread(delegate ()
{
using (Child child = new Child())
{
child.MyName = "2";
child.ShowDialog();
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}