I have a C# application which runs as a context menu in the system tray. One of the options will display a ‘system information’ box and at the moment I’m opening this window in another thread (on click event) like this…
void menu_SystemInformation_Click(object sender, EventArgs e)
{
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(menu_Systeminformation_Thread));
t.Start();
}
void menu_Systeminformation_Thread()
{
Application.Run(new SystemInformation());
}
I have two questions about this…
- How can I make sure that only one instance of this form is opened when the option is selected.
- How can I automatically close this form (if it’s open) when the application closes.
Any help is appreciated. I’ve only been doing C# for a few weeks, so go easy on me!
Cheers,
Programming. Have a central location, check whether you already have an open window. There is no automatism for that, but it is trivial to do.
You dont do anything. THe process closes, all windows get closed anyway. All open OS resources are rleased, including files etc.