Skip to content

Commit

Permalink
ProcessInfoCollector fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lilla28 committed May 22, 2023
1 parent 8dac053 commit 8d607d8
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ private async void ConnectionStatusChangedHandler(object? sender, ConnectionInfo
}
}

connections = new List<KeyValuePair<RuntimeInformation, ConnectionInfo>>()
connections = new Dictionary<RuntimeInformation, ConnectionInfo>()
{
new(_runtimeId, connection)
{ _runtimeId, connection }
};
}
}
Expand All @@ -106,8 +106,7 @@ private async void ConnectionStatusChangedHandler(object? sender, ConnectionInfo
return;
}

if (connections.Any())
await _communicator.UpdateConnectionInformation(connections);
await _communicator.UpdateConnectionInformation(connections);
}

public async Task SendRuntimeInfo()
Expand All @@ -116,9 +115,9 @@ public async Task SendRuntimeInfo()

lock(_locker)
{
runtimeInfo = new List<KeyValuePair<RuntimeInformation, ProcessInfoCollectorData>>()
runtimeInfo = new Dictionary<RuntimeInformation, ProcessInfoCollectorData>()
{
new(_runtimeId, _processInformation)
{ _runtimeId, _processInformation }
};
}

Expand Down Expand Up @@ -150,16 +149,13 @@ public async Task AddEnvironmentVariables(EnvironmentMonitorInfo environmentVari
_processInformation.EnvironmentVariables.AddOrUpdate(env.Key, env.Value, (_, _) => env.Value);
}

info = new List<KeyValuePair<RuntimeInformation, IEnumerable<KeyValuePair<string, string>>>>()
info = new Dictionary<RuntimeInformation, IEnumerable<KeyValuePair<string, string>>>()
{
new(_runtimeId, environmentVariables.EnvironmentVariables)
{ _runtimeId, environmentVariables.EnvironmentVariables }
};
}

if (info.Any())
{
await _communicator.UpdateEnvironmentVariableInformation(info);
}
await _communicator.UpdateEnvironmentVariableInformation(info);
}

private async Task AddOrUpdateElements<T>(
Expand Down Expand Up @@ -194,7 +190,7 @@ private async Task AddOrUpdateElements<T>(
}
}

info = new List<KeyValuePair<RuntimeInformation, IEnumerable<T>>>() { new(_runtimeId, source) };
info = new Dictionary<RuntimeInformation, IEnumerable<T>>() { { _runtimeId, source } };
}

await handler(info);
Expand Down

0 comments on commit 8d607d8

Please sign in to comment.