mirror of https://github.com/2dust/v2rayN
fix infinite loop thread hang there causes v2rayN hang in the background
修复死循环线程导致v2rayN在用户点击退出仍挂在后台pull/36/head
parent
fe015b0227
commit
83e7ad9360
|
@ -1020,6 +1020,9 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
this.Visible = false;
|
this.Visible = false;
|
||||||
this.Close();
|
this.Close();
|
||||||
|
|
||||||
|
statistics.Close();
|
||||||
|
|
||||||
//this.Dispose();
|
//this.Dispose();
|
||||||
//System.Environment.Exit(System.Environment.ExitCode);
|
//System.Environment.Exit(System.Environment.ExitCode);
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
private string logPath_;
|
private string logPath_;
|
||||||
|
|
||||||
|
private bool exitFlag_; // true to close workThread_
|
||||||
|
|
||||||
public StatisticsHandler(Config config, Action<ulong, ulong, ulong, ulong, List<Mode.ServerStatistics>> update)
|
public StatisticsHandler(Config config, Action<ulong, ulong, ulong, ulong, List<Mode.ServerStatistics>> update)
|
||||||
{
|
{
|
||||||
config_ = config;
|
config_ = config;
|
||||||
|
@ -55,6 +57,7 @@ namespace v2rayN.Handler
|
||||||
updateFunc_ = update;
|
updateFunc_ = update;
|
||||||
logPath_ = Utils.GetPath($"{Global.StatisticLogDirectory}\\");
|
logPath_ = Utils.GetPath($"{Global.StatisticLogDirectory}\\");
|
||||||
Statistic = new List<Mode.ServerStatistics>();
|
Statistic = new List<Mode.ServerStatistics>();
|
||||||
|
exitFlag_ = false;
|
||||||
|
|
||||||
DeleteExpiredLog();
|
DeleteExpiredLog();
|
||||||
foreach (var server in config.vmess)
|
foreach (var server in config.vmess)
|
||||||
|
@ -90,11 +93,17 @@ namespace v2rayN.Handler
|
||||||
workThread_.Start();
|
workThread_.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
exitFlag_ = true;
|
||||||
|
connector_.Kill();
|
||||||
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (true)
|
while (!exitFlag_)
|
||||||
{
|
{
|
||||||
if (enabled_)
|
if (enabled_)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue