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.Close();
|
||||
|
||||
statistics.Close();
|
||||
|
||||
//this.Dispose();
|
||||
//System.Environment.Exit(System.Environment.ExitCode);
|
||||
Application.Exit();
|
||||
|
|
|
@ -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_)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue