Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Nov 2, 2024
1 parent c339aa3 commit 201cfaa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion v2rayN/ServiceLib/Enums/EMsgCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum EMsgCommand
ClearMsg,
SendMsgView,
SendSnackMsg,
RefreshProfiles
RefreshProfiles,
StopSpeedtest
}
}
8 changes: 5 additions & 3 deletions v2rayN/ServiceLib/Services/SpeedtestService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Diagnostics;
using ReactiveUI;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;

namespace ServiceLib.Services
{
public class SpeedtestService
Expand Down Expand Up @@ -80,10 +80,12 @@ public SpeedtestService(Config config, List<ProfileItem> selecteds, ESpeedAction
Task.Run(RunMixedtestAsync);
break;
}
MessageBus.Current.Listen<string>(EMsgCommand.StopSpeedtest.ToString()).Subscribe(ExitLoop);
}

public void ExitLoop()
private void ExitLoop(string x)
{
if(_exitLoop) return;
_exitLoop = true;
UpdateFunc("", ResUI.SpeedtestingStop);
}
Expand Down
6 changes: 3 additions & 3 deletions v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class ProfilesViewModel : MyReactiveObject
private List<ProfileItem> _lstProfile;
private string _serverFilter = string.Empty;
private Dictionary<string, bool> _dicHeaderSort = new();
private SpeedtestService? _speedtestHandler;

#endregion private prop

Expand Down Expand Up @@ -686,12 +685,13 @@ public async Task ServerSpeedtest(ESpeedActionType actionType)
}
//ClearTestResult();

_speedtestHandler = new SpeedtestService(_config, lstSelecteds, actionType, UpdateSpeedtestHandler);
_ = new SpeedtestService(_config, lstSelecteds, actionType, UpdateSpeedtestHandler);

}

public void ServerSpeedtestStop()
{
_speedtestHandler?.ExitLoop();
MessageBus.Current.SendMessage("", EMsgCommand.StopSpeedtest.ToString());
}

private async Task Export2ClientConfigAsync(bool blClipboard)
Expand Down

0 comments on commit 201cfaa

Please sign in to comment.