Determining when the form is closed should be easy enough, look into delegates and event handling. You should be able to have your child form send a message to the parent form when it closes. An even easier way, actually, would be to pass a reference to the main form to your child form, then in the child form's form closing event, notify the parent in whatever way you prefer. You've got a fair amount of options here :)
As for restarting the main application, that's a little different. To my knowledge, once the application closes that's it, you've lost control. That said, if you set up a controlling loop for your application (ie, your main form isn't the entry point), then you can restart it. I suppose you technically have this in Program.cs...
- Application.Run(new MyForm());
I've never done it myself, but in theory couldn't you do something like...
- Application.EnableVisualStyles();
-
Application.SetCompatibleTextRenderingDefault(false);
-
bool restartApp = false;
-
do
-
{
-
MyForm form = new MyForm();
-
Application.Run(form);
-
restartApp = form.Restart;
-
} while (restartApp == true);
Make a property on your main form called Restart, and have it true whenever the app needs to be restarted, false otherwise.
I hope that helps :)
*Edit: Cloud snuck a response in while I was writing... his answer is much better than mine, I didn't know about that... heh, that's why I love coming to this forum :)