Skip to content

Commit

Permalink
Use ObjectDisposedException.ThrowIf where available
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeago committed Nov 20, 2023
1 parent 63b2c39 commit 5681040
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Louis/Threading/AsyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,15 @@ private void UnsafeSetState(AsyncServiceState value)
LogStateChanged(oldState, _state);
}

#if NET7_0_OR_GREATER
private void EnsureNotDisposed() => ObjectDisposedException.ThrowIf(_disposed.Value, GetType());
#else
private void EnsureNotDisposed()
{
if (_disposed.Value)
{
throw new ObjectDisposedException(GetType().Name);
}
}
#endif
}

0 comments on commit 5681040

Please sign in to comment.