static void Main(string[] args) { bool second = false; bool createNew = false; using (Mutex mutex = new Mutex(true, Application.ProductName, out createNew)) { if (!createNew) { var r = MessageBox.Show("数据上传程序(HTTP)已经在运行中...", "选择是否允许第二个数据上传代理", MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { second = true; } else { return; } } try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainDataAgentWindow form = new MainDataAgentWindow(); form.IsSecond = second; Application.Run(form); } catch (Exception e) { MessageBox.Show(e.Message); } } }
static void Main(string[] args) { bool createNew = false; using (Mutex mutex = new Mutex(true, Application.ProductName, out createNew)) { if (createNew) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainDataAgentWindow form = new MainDataAgentWindow(); Application.Run(form); } catch (Exception e) { MessageBox.Show(e.Message); } } else { MessageBox.Show("数据上传程序(HTTP)已经在运行中..."); } } }