Skip to content

Commit dd05263

Browse files
committed
修改多进程提示框样式
1 parent 38ef5e0 commit dd05263

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

TimeControl/Program.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,6 @@ private static void Main(string[] args)
2626
hide = true;
2727
}
2828
}
29-
Process[] processes = Process.GetProcessesByName("TimeControl");
30-
if (processes.Length > 1)
31-
{
32-
if (MessageBox.Show(
33-
"当前已经启动TimeControl,不能启动多个实例,是否要重新启动?",
34-
"提示",
35-
MessageBoxButtons.OKCancel,
36-
MessageBoxIcon.Information) == DialogResult.OK)
37-
{
38-
foreach (Process process in processes)
39-
{
40-
if (process.Id != Environment.ProcessId)
41-
process.Kill();
42-
}
43-
}
44-
else
45-
return;
46-
}
4729
if (!Debugger.IsAttached)
4830
{
4931
Application.ThreadException += ExceptionHandler;

TimeControl/Windows/ControlPanel.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ public partial class ControlPanel : Form
2222
private TimeData timeData;//数据
2323
public ControlPanel(bool hide)
2424
{
25+
Process[] processes = Process.GetProcessesByName("TimeControl");
26+
if (processes.Length > 1)
27+
{
28+
if (MessageBox.Show(
29+
"当前已经启动TimeControl,不能启动多个实例,是否要重新启动?",
30+
"提示",
31+
MessageBoxButtons.OKCancel,
32+
MessageBoxIcon.Information) == DialogResult.OK)
33+
{
34+
foreach (Process process in processes)
35+
{
36+
if (process.Id != Environment.ProcessId)
37+
process.Kill();
38+
}
39+
}
40+
else
41+
Environment.Exit(0);
42+
}
2543
InitializeComponent();
2644
this.hide = hide;
2745
//数据记录

0 commit comments

Comments
 (0)