private void MainWin_Shown(object sender, EventArgs e) { { string logFile = ProcMain.SelfFile + ".G3_MainWin.log"; SCommon.DeletePath(logFile); ProcMain.WriteLog = message => { using (StreamWriter writer = new StreamWriter(logFile, true, Encoding.UTF8)) { writer.WriteLine("[" + DateTime.Now + "] " + message); } }; } bool aliving = true; this.PostGameStart_G3 = () => { this.BeginInvoke((MethodInvoker) delegate { if (aliving) { this.Visible = false; } }); this.PostGameStart_G3 = null; }; Thread th = new Thread(() => { I = this; new Program2().Main2(); LiteStatusDlg.EndDisplay(); I = null; this.BeginInvoke((MethodInvoker) delegate { aliving = false; this.Close(); }); }); th.Start(); }