static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (var mw = new MainWindow()) { if (mw.ShowDialog() != DialogResult.OK) return; } Application.Run(new Form1()); }