static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new MainWindow()); MainWindow mw = new MainWindow(); mw.Show(); while (mw.Visible) { Application.DoEvents(); mw.DispatchDrawingEvents(); } }