static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); currentPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //监听退出进程 var CurrentPro = Process.GetCurrentProcess(); CurrentPro.EnableRaisingEvents = true; CurrentPro.Exited += new EventHandler(Pro_Exit); mainWind = new MainWin(); //启动必要的线程 servercontrol = new ServerControl(); viewcontrol = new ViewControl(mainWind); servercontrol.StartListenThread(); viewcontrol.StartListenServerThread(); mainWind.FormClosed += new FormClosedEventHandler(FormExit); Application.Run(mainWind); }