44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace FemboyWatchdog
|
|
{
|
|
public class MultiFormContext : ApplicationContext
|
|
{
|
|
private int openForms;
|
|
public MultiFormContext(params Form[] forms)
|
|
{
|
|
openForms = forms.Length;
|
|
|
|
foreach (var form in forms)
|
|
{
|
|
form.FormClosed += (s, args) =>
|
|
{
|
|
//When we have closed the last of the "starting" forms,
|
|
//end the program.
|
|
if (Interlocked.Decrement(ref openForms) == 0)
|
|
ExitThread();
|
|
};
|
|
|
|
form.Show();
|
|
}
|
|
}
|
|
}
|
|
|
|
static class Program
|
|
{
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main()
|
|
{
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
Application.Run(new MultiFormContext(new Monitor(), new Toolbar()));
|
|
}
|
|
}
|
|
}
|