public MainForm() { CheckForIllegalCrossThreadCalls = false; string proc = Process.GetCurrentProcess().ProcessName; int id = Process.GetCurrentProcess().Id; Process[] lst = Process.GetProcesses(); foreach (Process p in lst) { if (p.ProcessName != proc || p.Id == id) { continue; } MessageBox.Show("This program is already open"); Process.GetCurrentProcess().Kill(); return; } InitializeComponent(); VariousFunctions.DeleteFile(Application.StartupPath + "/LFLiveUpdater.exe"); bool devmode = AssemblyFunctions.GrabParentProcessName() == "devenv"; Thread y = new Thread(new ParameterizedThreadStart(upd)); y.Start(devmode); Thread x = new Thread(new ParameterizedThreadStart(startss)); x.Start(devmode); VariousFunctions.DeleteTempFiles(); Thread z = new Thread(new ThreadStart(readrss)); z.Start(); PublicKV = new RSAParams(Application.StartupPath + "/KV.bin"); if (!PublicKV.Valid) { MessageBox.Show("Cannot load KV"); Process.GetCurrentProcess().Kill(); return; } XAbout.WriteLegalLocally(); while (x.IsAlive) { Application.DoEvents(); } Show(); while (y.IsAlive) { Application.DoEvents(); } Enabled = true; Select(); Focus(); if (!devmode) { updr.Dispose(); updr = null; } checkForUpdatesToolStripMenuItem.Enabled = true; }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { VariousFunctions.DeleteTempFiles(); }