mirror of https://github.com/2dust/v2rayN
优化代码-ThreadStart改用Task
parent
aee8994c41
commit
b6d1c4330f
|
@ -15,7 +15,6 @@ namespace v2rayN.Handler
|
|||
private Config _config;
|
||||
private V2rayHandler _v2rayHandler;
|
||||
private List<int> _selecteds;
|
||||
private Thread _workThread;
|
||||
Action<int, string> _updateFunc;
|
||||
|
||||
private int testCounter = 0;
|
||||
|
@ -36,25 +35,19 @@ namespace v2rayN.Handler
|
|||
|
||||
if (actionType == "ping")
|
||||
{
|
||||
_workThread = new Thread(new ThreadStart(RunPing));
|
||||
_workThread.IsBackground = true;
|
||||
_workThread.Start();
|
||||
Task.Factory.StartNew(() => RunPing());
|
||||
}
|
||||
if (actionType == "tcping")
|
||||
{
|
||||
_workThread = new Thread(new ThreadStart(RunTcping));
|
||||
_workThread.IsBackground = true;
|
||||
_workThread.Start();
|
||||
Task.Factory.StartNew(() => RunTcping());
|
||||
}
|
||||
else if (actionType == "realping")
|
||||
{
|
||||
_workThread = new Thread(new ThreadStart(RunRealPing));
|
||||
_workThread.IsBackground = true;
|
||||
_workThread.Start();
|
||||
Task.Factory.StartNew(() => RunRealPing());
|
||||
}
|
||||
else if (actionType == "speedtest")
|
||||
{
|
||||
RunSpeedTest();
|
||||
Task.Factory.StartNew(() => RunSpeedTest());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using v2rayN.Mode;
|
||||
using v2rayN.Properties;
|
||||
using v2rayN.Protos.Statistics;
|
||||
|
@ -18,7 +19,6 @@ namespace v2rayN.Handler
|
|||
private ServerStatistics serverStatistics_;
|
||||
private Channel channel_;
|
||||
private StatsService.StatsServiceClient client_;
|
||||
private Thread workThread_;
|
||||
private bool exitFlag_;
|
||||
|
||||
Action<ulong, ulong, List<ServerStatItem>> updateFunc_;
|
||||
|
@ -70,9 +70,7 @@ namespace v2rayN.Handler
|
|||
|
||||
GrpcInit();
|
||||
|
||||
workThread_ = new Thread(new ThreadStart(Run));
|
||||
workThread_.IsBackground = true;
|
||||
workThread_.Start();
|
||||
Task.Factory.StartNew(() => Run());
|
||||
}
|
||||
|
||||
private void GrpcInit()
|
||||
|
|
Loading…
Reference in New Issue