2dust 2024-11-02 15:02:30 +08:00
parent c339aa349c
commit 201cfaa922
3 changed files with 10 additions and 7 deletions

View file

@ -5,6 +5,7 @@
ClearMsg, ClearMsg,
SendMsgView, SendMsgView,
SendSnackMsg, SendSnackMsg,
RefreshProfiles RefreshProfiles,
StopSpeedtest
} }
} }

View file

@ -1,7 +1,7 @@
using System.Diagnostics; using ReactiveUI;
using System.Diagnostics;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
namespace ServiceLib.Services namespace ServiceLib.Services
{ {
public class SpeedtestService public class SpeedtestService
@ -80,10 +80,12 @@ namespace ServiceLib.Services
Task.Run(RunMixedtestAsync); Task.Run(RunMixedtestAsync);
break; break;
} }
MessageBus.Current.Listen<string>(EMsgCommand.StopSpeedtest.ToString()).Subscribe(ExitLoop);
} }
public void ExitLoop() private void ExitLoop(string x)
{ {
if(_exitLoop) return;
_exitLoop = true; _exitLoop = true;
UpdateFunc("", ResUI.SpeedtestingStop); UpdateFunc("", ResUI.SpeedtestingStop);
} }

View file

@ -16,7 +16,6 @@ namespace ServiceLib.ViewModels
private List<ProfileItem> _lstProfile; private List<ProfileItem> _lstProfile;
private string _serverFilter = string.Empty; private string _serverFilter = string.Empty;
private Dictionary<string, bool> _dicHeaderSort = new(); private Dictionary<string, bool> _dicHeaderSort = new();
private SpeedtestService? _speedtestHandler;
#endregion private prop #endregion private prop
@ -686,12 +685,13 @@ namespace ServiceLib.ViewModels
} }
//ClearTestResult(); //ClearTestResult();
_speedtestHandler = new SpeedtestService(_config, lstSelecteds, actionType, UpdateSpeedtestHandler); _ = new SpeedtestService(_config, lstSelecteds, actionType, UpdateSpeedtestHandler);
} }
public void ServerSpeedtestStop() public void ServerSpeedtestStop()
{ {
_speedtestHandler?.ExitLoop(); MessageBus.Current.SendMessage("", EMsgCommand.StopSpeedtest.ToString());
} }
private async Task Export2ClientConfigAsync(bool blClipboard) private async Task Export2ClientConfigAsync(bool blClipboard)