private void MainWin_FormClosed(object sender, FormClosedEventArgs e) { if (Gnd.I.SettingData.KeepPrimeDat == false) { // Prime64.exe の終了待ち。 { Process p; { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = Gnd.I.Prime64File; psi.Arguments = "/P 1"; psi.CreateNoWindow = true; psi.UseShellExecute = false; p = Process.Start(psi); } using (BusyDlg f = new BusyDlg()) { f.SetInterval(delegate { return(p.HasExited == false); }); f.SetMessage("プログラムを終了しています..."); f.ShowDialog(); } } using (Mutex m = new Mutex(false, Gnd.I.FACTORY_COMMON_MUTEX)) using (new IMutex(m)) { File.Delete("Prime.dat"); } } }
private void MainWin_Load(object sender, EventArgs e) { this.MinimumSize = this.Size; { bool existsPrimeDat; using (Mutex m = new Mutex(false, Gnd.I.FACTORY_COMMON_MUTEX)) using (new IMutex(m)) { existsPrimeDat = File.Exists("Prime.dat"); } if (existsPrimeDat == false) { // Prime.dat のため、ディスクの空きチェック { DriveInfo di = new DriveInfo(BootTools.SelfDir.Substring(0, 2)); int diskFree_mb = IntTools.ToInt(di.AvailableFreeSpace / 1000000.0); if (diskFree_mb < Gnd.I.SettingData.DiskFreeOnBoot_MB) // ? < 300 MB { string message = "起動に必要なディスクの空き領域が不足しています。(" + diskFree_mb + "_" + Gnd.I.SettingData.DiskFreeOnBoot_MB + ")"; MessageBox.Show(message, Program.APP_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); throw new Exception(message); } } #if true { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = Gnd.I.Prime64File; psi.Arguments = "/P 1"; psi.CreateNoWindow = true; psi.UseShellExecute = false; Process.Start(psi); // 待たない! } #else // old @ 2017.5.17 this.ProcMan.Start(Gnd.I.Prime64File, "/P 1"); using (BusyDlg f = new BusyDlg()) { f.SetInterval(delegate { return(this.ProcMan.IsEnd() == false); }); f.SetMessage("データファイルを作成しています..."); f.ShowDialog(); this.Location = f.Location; } if (Gnd.I.SettingData.HidePrimeDat) { this.ProcMan.Start("ATTRIB.EXE", "+S +H Prime.dat"); this.ProcMan.End(); } #endif } } }