Improved Action Invoke

This commit is contained in:
2dust
2024-10-08 13:47:13 +08:00
parent 3e74bb65bd
commit 53e19ecb1d
16 changed files with 113 additions and 126 deletions
@@ -9,12 +9,12 @@ namespace ServiceLib.Services.Statistics
private bool _exitFlag;
private ClientWebSocket? webSocket;
private string url = string.Empty;
private Action<ServerSpeedItem> _updateFunc;
private Action<ServerSpeedItem>? _updateFunc;
public StatisticsSingboxService(Config config, Action<ServerSpeedItem> update)
public StatisticsSingboxService(Config config, Action<ServerSpeedItem> updateFunc)
{
_config = config;
_updateFunc = update;
_updateFunc = updateFunc;
_exitFlag = false;
Task.Run(() => Run());
@@ -92,7 +92,7 @@ namespace ServiceLib.Services.Statistics
{
ParseOutput(result, out ulong up, out ulong down);
_updateFunc(new ServerSpeedItem()
_updateFunc?.Invoke(new ServerSpeedItem()
{
proxyUp = (long)(up / 1000),
proxyDown = (long)(down / 1000)