@@ -19,14 +19,19 @@ public void RunLoop(ESpeedActionType actionType, List<ProfileItem> selecteds)
1919
2020 public void ExitLoop ( )
2121 {
22- if ( _lstExitLoop . Count > 0 )
22+ if ( ! _lstExitLoop . IsEmpty )
2323 {
2424 _ = UpdateFunc ( "" , ResUI . SpeedtestingStop ) ;
2525
2626 _lstExitLoop . Clear ( ) ;
2727 }
2828 }
2929
30+ private static bool ShouldStopTest ( string exitLoopKey )
31+ {
32+ return ! _lstExitLoop . Any ( p => p == exitLoopKey ) ;
33+ }
34+
3035 private async Task RunAsync ( ESpeedActionType actionType , List < ProfileItem > selecteds )
3136 {
3237 var exitLoopKey = Utils . GetGuid ( false ) ;
@@ -103,6 +108,11 @@ private async Task<List<ServerTestItem>> GetClearItem(ESpeedActionType actionTyp
103108 }
104109 }
105110
111+ if ( lstSelected . Count > 1 && ( actionType == ESpeedActionType . Speedtest || actionType == ESpeedActionType . Mixedtest ) )
112+ {
113+ NoticeManager . Instance . Enqueue ( ResUI . SpeedtestingPressEscToExit ) ;
114+ }
115+
106116 return lstSelected ;
107117 }
108118
@@ -152,7 +162,7 @@ private async Task RunRealPingBatchAsync(List<ServerTestItem> lstSelected, strin
152162 var pageSizeNext = pageSize / 2 ;
153163 if ( lstFailed . Count > 0 && pageSizeNext > 0 )
154164 {
155- if ( _lstExitLoop . Any ( p => p == exitLoopKey ) == false )
165+ if ( ShouldStopTest ( exitLoopKey ) )
156166 {
157167 await UpdateFunc ( "" , ResUI . SpeedtestingSkip ) ;
158168 return ;
@@ -190,6 +200,12 @@ private async Task<bool> RunRealPingAsync(List<ServerTestItem> selecteds, string
190200 {
191201 continue ;
192202 }
203+
204+ if ( ShouldStopTest ( exitLoopKey ) )
205+ {
206+ return false ;
207+ }
208+
193209 tasks . Add ( Task . Run ( async ( ) =>
194210 {
195211 await DoRealPing ( it ) ;
@@ -218,7 +234,7 @@ private async Task RunMixedTestAsync(List<ServerTestItem> selecteds, int concurr
218234 List < Task > tasks = new ( ) ;
219235 foreach ( var it in selecteds )
220236 {
221- if ( _lstExitLoop . Any ( p => p == exitLoopKey ) == false )
237+ if ( ShouldStopTest ( exitLoopKey ) )
222238 {
223239 await UpdateFunc ( it . IndexId , "" , ResUI . SpeedtestingSkip ) ;
224240 continue ;
@@ -234,21 +250,27 @@ private async Task RunMixedTestAsync(List<ServerTestItem> selecteds, int concurr
234250 if ( processService is null )
235251 {
236252 await UpdateFunc ( it . IndexId , "" , ResUI . FailedToRunCore ) ;
253+ return ;
237254 }
238- else
255+
256+ await Task . Delay ( 1000 ) ;
257+
258+ var delay = await DoRealPing ( it ) ;
259+ if ( blSpeedTest )
239260 {
240- await Task . Delay ( 1000 ) ;
241- var delay = await DoRealPing ( it ) ;
242- if ( blSpeedTest )
261+ if ( ShouldStopTest ( exitLoopKey ) )
262+ {
263+ await UpdateFunc ( it . IndexId , "" , ResUI . SpeedtestingSkip ) ;
264+ return ;
265+ }
266+
267+ if ( delay > 0 )
268+ {
269+ await DoSpeedTest ( downloadHandle , it ) ;
270+ }
271+ else
243272 {
244- if ( delay > 0 )
245- {
246- await DoSpeedTest ( downloadHandle , it ) ;
247- }
248- else
249- {
250- await UpdateFunc ( it . IndexId , "" , ResUI . SpeedtestingSkip ) ;
251- }
273+ await UpdateFunc ( it . IndexId , "" , ResUI . SpeedtestingSkip ) ;
252274 }
253275 }
254276 }
0 commit comments