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