Skip to content

Commit

Permalink
Fix #1069
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszCichecki committed Dec 9, 2023
1 parent 0634174 commit a2cd862
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 6 additions & 1 deletion LenovoLegionToolkit.Lib/AutoListeners/GameAutoListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ private void Process_Exited(object? o, EventArgs args)
if (Log.Instance.IsTraceEnabled)
Log.Instance.Trace($"Process {process.Id} exited.");

var staleProcesses = _processCache.RemoveWhere(p => p.HasExited);
var staleProcesses = _processCache.RemoveWhere(p =>
{
try { return p.HasExited; }
catch { return true; }
});

if (staleProcesses > 1)
{
if (Log.Instance.IsTraceEnabled)
Expand Down
4 changes: 1 addition & 3 deletions LenovoLegionToolkit.Lib/AutoListeners/ProcessAutoListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ private void InstanceStoppedEventAutoAutoListener_Changed(object? sender, (int p
if (IgnoredNames.Contains(e.processName, StringComparer.InvariantCultureIgnoreCase))
return;

if (!_processCache.TryGetValue(e.processId, out var processInfo))
if (!_processCache.Remove(e.processId, out var processInfo))
return;

_processCache.Remove(e.processId);

RaiseChanged(new(ProcessEventInfoType.Stopped, processInfo));
}
}
Expand Down

0 comments on commit a2cd862

Please sign in to comment.