From 568104010969bdf0d40e7de8cf612544986ba060 Mon Sep 17 00:00:00 2001 From: Riccardo De Agostini Date: Mon, 20 Nov 2023 02:57:09 +0100 Subject: [PATCH] Use ObjectDisposedException.ThrowIf where available --- src/Louis/Threading/AsyncService.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Louis/Threading/AsyncService.cs b/src/Louis/Threading/AsyncService.cs index 1686206..9e85758 100644 --- a/src/Louis/Threading/AsyncService.cs +++ b/src/Louis/Threading/AsyncService.cs @@ -589,6 +589,9 @@ 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) @@ -596,4 +599,5 @@ private void EnsureNotDisposed() throw new ObjectDisposedException(GetType().Name); } } +#endif }