-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMyThread.cs
38 lines (35 loc) · 1.05 KB
/
MyThread.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ClashNet
{
class MyThread
{
private Process process;
private NotifyIcon notifyIcon;
public MyThread(Process process, NotifyIcon notifyIcon)
{
this.process = process;
this.notifyIcon = notifyIcon;
}
public void ThreadMain()
{
// 这里需要起一个新的线程来做这件事,不然程序就死在这里了
while (!process.HasExited && !process.StandardOutput.EndOfStream)
{
string line = process.StandardOutput.ReadLine();
// do something with line
Console.WriteLine(line);
}
if(process.ExitCode!=0)
{
notifyIcon.BalloonTipText = "Clash 启动失败,请查看错误日志";
notifyIcon.ShowBalloonTip(2000);
}
}
}
}