mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-15 08:55:00 +03:00
Fix TCPing tests not stopping when ESC is pressed (#9623)
This commit is contained in:
@@ -46,7 +46,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
|||||||
switch (actionType)
|
switch (actionType)
|
||||||
{
|
{
|
||||||
case ESpeedActionType.Tcping:
|
case ESpeedActionType.Tcping:
|
||||||
await RunTcpingAsync(lstSelected);
|
await RunTcpingAsync(lstSelected, exitLoopKey);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESpeedActionType.Realping:
|
case ESpeedActionType.Realping:
|
||||||
@@ -135,16 +135,28 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
|||||||
return lstSelected;
|
return lstSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RunTcpingAsync(List<ServerTestItem> selecteds)
|
private async Task RunTcpingAsync(List<ServerTestItem> selecteds, string exitLoopKey)
|
||||||
{
|
{
|
||||||
var pageSize = Math.Min(selecteds.Count, _speedTestPageSize);
|
var pageSize = Math.Min(selecteds.Count, _speedTestPageSize);
|
||||||
var lstBatch = GetTestBatchItem(selecteds, pageSize);
|
var lstBatch = GetTestBatchItem(selecteds, pageSize);
|
||||||
|
|
||||||
foreach (var lst in lstBatch)
|
foreach (var lst in lstBatch)
|
||||||
{
|
{
|
||||||
|
if (ShouldStopTest(exitLoopKey))
|
||||||
|
{
|
||||||
|
await UpdateFunc("", ResUI.SpeedtestingSkip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<Task> tasks = [];
|
List<Task> tasks = [];
|
||||||
|
|
||||||
foreach (var it in lst)
|
foreach (var it in lst)
|
||||||
{
|
{
|
||||||
|
if (ShouldStopTest(exitLoopKey))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tasks.Add(Task.Run(async () =>
|
tasks.Add(Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -160,7 +172,14 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
|
|
||||||
|
if (ShouldStopTest(exitLoopKey))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await Task.Delay(_delayInterval);
|
await Task.Delay(_delayInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user