Program.cs中代码如下:
using System; using System.Collections.Generic; using System.Windows.Forms; namespace test1 { public static class Program { public static Main main; public static Main GetMain() { if (main == null || main.IsDisposed) { main = new Main(); } return main; } /// <summary> /// 应用程序的主入口点。 /// </summary> [MTAThread] public static void Main() { Application.Run(GetMain()); } } }
调用如下:
private void button3_Click(object sender, EventArgs e) { Program.GetMain().Show(); }