using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace WindowsFormsApplication1 { static class Program { /// /// アプリケーションのメイン エントリ ポイントです。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form[] forms = new Form[3]; for (int i = 0; i < forms.Length; ++i) { forms[i] = new Form(); forms[i].FormClosed += (sender, e) => { int count = 0; foreach (Form f in forms) { if (f.Visible == false) count++; } if (count == 2) Application.Exit(); }; forms[i].Show(); } Application.Run(); } } }