Skip to content

Commit 2ffee96

Browse files
author
devizer
committed
Added handling of missing required Stop()
1 parent 0edd731 commit 2ffee96

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Universe.CpuUsage/CpuUsageAsyncWatcher.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ private void ContextChangedHandler(AsyncLocalValueChangedArgs<object> args)
8484
{
8585
var contextOnStart = ContextItem.Value;
8686
ContextItem.Value = null;
87-
if (contextOnStart == null) throw new InvalidOperationException(
88-
"CpuUsageAsyncWatcher.OnEnd: Missing contextOnStart. Please report");
87+
if (contextOnStart == null)
88+
{
89+
// .Stop() lost, Force Stop()
90+
IsRunning = false;
91+
// throw new InvalidOperationException("CpuUsageAsyncWatcher.OnEnd: Missing contextOnStart. Please report");
92+
}
8993

9094
if (tid != contextOnStart.ThreadId)
9195
throw new InvalidOperationException(

0 commit comments

Comments
 (0)