fix infinite loop thread hang there causes v2rayN hang in the background

修复死循环线程导致v2rayN在用户点击退出仍挂在后台
pull/36/head
CGQAQ 2019-08-26 09:32:45 +08:00
parent fe015b0227
commit 83e7ad9360
2 changed files with 13 additions and 1 deletions

View File

@ -1020,6 +1020,9 @@ namespace v2rayN.Forms
this.Visible = false;
this.Close();
statistics.Close();
//this.Dispose();
//System.Environment.Exit(System.Environment.ExitCode);
Application.Exit();

View File

@ -47,6 +47,8 @@ namespace v2rayN.Handler
private string logPath_;
private bool exitFlag_; // true to close workThread_
public StatisticsHandler(Config config, Action<ulong, ulong, ulong, ulong, List<Mode.ServerStatistics>> update)
{
config_ = config;
@ -55,6 +57,7 @@ namespace v2rayN.Handler
updateFunc_ = update;
logPath_ = Utils.GetPath($"{Global.StatisticLogDirectory}\\");
Statistic = new List<Mode.ServerStatistics>();
exitFlag_ = false;
DeleteExpiredLog();
foreach (var server in config.vmess)
@ -90,11 +93,17 @@ namespace v2rayN.Handler
workThread_.Start();
}
public void Close()
{
exitFlag_ = true;
connector_.Kill();
}
public void run()
{
try
{
while (true)
while (!exitFlag_)
{
if (enabled_)
{