mirror of https://github.com/2dust/v2rayN
use Task.Delay instead of Thread.Sleep
parent
982c865245
commit
abe484b0df
|
@ -160,9 +160,9 @@ namespace v2rayN.Handler
|
||||||
Task.Run(() => UpdateTaskRunGeo(config, update));
|
Task.Run(() => UpdateTaskRunGeo(config, update));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTaskRunSubscription(Config config, Action<bool, string> update)
|
private async Task UpdateTaskRunSubscription(Config config, Action<bool, string> update)
|
||||||
{
|
{
|
||||||
Thread.Sleep(60000);
|
await Task.Delay(60000);
|
||||||
Utils.SaveLog("UpdateTaskRunSubscription");
|
Utils.SaveLog("UpdateTaskRunSubscription");
|
||||||
|
|
||||||
var updateHandle = new UpdateHandle();
|
var updateHandle = new UpdateHandle();
|
||||||
|
@ -185,17 +185,17 @@ namespace v2rayN.Handler
|
||||||
item.updateTime = updateTime;
|
item.updateTime = updateTime;
|
||||||
ConfigHandler.AddSubItem(ref config, item);
|
ConfigHandler.AddSubItem(ref config, item);
|
||||||
|
|
||||||
Thread.Sleep(5000);
|
await Task.Delay(5000);
|
||||||
}
|
}
|
||||||
Thread.Sleep(60000);
|
await Task.Delay(60000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTaskRunGeo(Config config, Action<bool, string> update)
|
private async Task UpdateTaskRunGeo(Config config, Action<bool, string> update)
|
||||||
{
|
{
|
||||||
var autoUpdateGeoTime = DateTime.Now;
|
var autoUpdateGeoTime = DateTime.Now;
|
||||||
|
|
||||||
Thread.Sleep(1000 * 120);
|
await Task.Delay(1000 * 120);
|
||||||
Utils.SaveLog("UpdateTaskRunGeo");
|
Utils.SaveLog("UpdateTaskRunGeo");
|
||||||
|
|
||||||
var updateHandle = new UpdateHandle();
|
var updateHandle = new UpdateHandle();
|
||||||
|
@ -214,7 +214,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(1000 * 3600);
|
await Task.Delay(1000 * 3600);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
_lstProfileEx = new(SqliteHelper.Instance.Table<ProfileExItem>());
|
_lstProfileEx = new(SqliteHelper.Instance.Table<ProfileExItem>());
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ namespace v2rayN.Handler
|
||||||
SqliteHelper.Instance.Replace(item);
|
SqliteHelper.Instance.Replace(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread.Sleep(1000 * 60);
|
await Task.Delay(1000 * 60);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunPingSub(Action<ServerTestItem> updateFun)
|
private async Task RunPingSubAsync(Action<ServerTestItem> updateFun)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(10);
|
await Task.Delay(10);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -119,21 +119,21 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunPing()
|
private async void RunPing()
|
||||||
{
|
{
|
||||||
RunPingSub((ServerTestItem it) =>
|
await RunPingSubAsync((ServerTestItem it) =>
|
||||||
{
|
{
|
||||||
long time = Ping(it.address);
|
long time = Ping(it.address);
|
||||||
var output = FormatOut(time, Global.DelayUnit);
|
var output = FormatOut(time, Global.DelayUnit);
|
||||||
|
|
||||||
ProfileExHandler.Instance.SetTestDelay(it.indexId, output);
|
ProfileExHandler.Instance.SetTestDelay(it.indexId, output);
|
||||||
UpdateFunc(it.indexId, output);
|
UpdateFunc(it.indexId, output);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunTcping()
|
private async void RunTcping()
|
||||||
{
|
{
|
||||||
RunPingSub((ServerTestItem it) =>
|
await RunPingSubAsync((ServerTestItem it) =>
|
||||||
{
|
{
|
||||||
int time = GetTcpingTime(it.address, it.port);
|
int time = GetTcpingTime(it.address, it.port);
|
||||||
var output = FormatOut(time, Global.DelayUnit);
|
var output = FormatOut(time, Global.DelayUnit);
|
||||||
|
@ -158,7 +158,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadHandle downloadHandle = new DownloadHandle();
|
DownloadHandle downloadHandle = new DownloadHandle();
|
||||||
//Thread.Sleep(5000);
|
|
||||||
List<Task> tasks = new();
|
List<Task> tasks = new();
|
||||||
foreach (var it in _selecteds)
|
foreach (var it in _selecteds)
|
||||||
{
|
{
|
||||||
|
@ -187,7 +187,6 @@ namespace v2rayN.Handler
|
||||||
Utils.SaveLog(ex.Message, ex);
|
Utils.SaveLog(ex.Message, ex);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
//Thread.Sleep(100);
|
|
||||||
}
|
}
|
||||||
Task.WaitAll(tasks.ToArray());
|
Task.WaitAll(tasks.ToArray());
|
||||||
}
|
}
|
||||||
|
@ -312,10 +311,10 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
UpdateFunc(it.indexId, "", msg);
|
UpdateFunc(it.indexId, "", msg);
|
||||||
});
|
});
|
||||||
Thread.Sleep(2000);
|
await Task.Delay(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep((timeout + 2) * 1000);
|
await Task.Delay((timeout + 2) * 1000);
|
||||||
|
|
||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
{
|
{
|
||||||
|
@ -329,7 +328,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
await RunRealPing();
|
await RunRealPing();
|
||||||
|
|
||||||
Thread.Sleep(1000);
|
await Task.Delay(1000);
|
||||||
|
|
||||||
await RunSpeedTestMulti();
|
await RunSpeedTestMulti();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
private async void Init()
|
private async void Init()
|
||||||
{
|
{
|
||||||
Thread.Sleep(5000);
|
await Task.Delay(5000);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var sleep = _config.guiItem.statisticsFreshRate < 1 ? 1 : _config.guiItem.statisticsFreshRate;
|
var sleep = _config.guiItem.statisticsFreshRate < 1 ? 1 : _config.guiItem.statisticsFreshRate;
|
||||||
Thread.Sleep(1000 * sleep);
|
await Task.Delay(1000 * sleep);
|
||||||
await _channel.ConnectAsync();
|
await _channel.ConnectAsync();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
|
@ -609,6 +609,7 @@ namespace v2rayN.Handler
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (needStop) coreHandler?.CoreStop();
|
if (needStop) coreHandler?.CoreStop();
|
||||||
|
Task.Delay(1000);
|
||||||
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
|
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
|
||||||
if (File.Exists(fileName))
|
if (File.Exists(fileName))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue