diff --git a/Directory.Packages.props b/Directory.Packages.props
index e8b9af959fb..fb622139459 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,6 +1,6 @@
- 7.0.0
+ 8.0.0
true
8.1.0
@@ -10,6 +10,7 @@
+
@@ -20,6 +21,7 @@
+
@@ -41,12 +43,4 @@
-
-
-
-
-
-
-
-
diff --git a/bench/Polly.Benchmarks/Polly.Benchmarks.csproj b/bench/Polly.Benchmarks/Polly.Benchmarks.csproj
index 53a3e563d6a..0fc02332e3f 100644
--- a/bench/Polly.Benchmarks/Polly.Benchmarks.csproj
+++ b/bench/Polly.Benchmarks/Polly.Benchmarks.csproj
@@ -2,7 +2,7 @@
false
Exe
- net6.0;net7.0
+ net6.0;net7.0;net8.0
enable
Benchmark
$(NoWarn);CA1822;SA1414;IDE0060
diff --git a/bench/Polly.Core.Benchmarks/Polly.Core.Benchmarks.csproj b/bench/Polly.Core.Benchmarks/Polly.Core.Benchmarks.csproj
index d7742e9db96..fd0ec851ece 100644
--- a/bench/Polly.Core.Benchmarks/Polly.Core.Benchmarks.csproj
+++ b/bench/Polly.Core.Benchmarks/Polly.Core.Benchmarks.csproj
@@ -1,6 +1,6 @@
- net7.0
+ net8.0;net7.0
Polly
true
Benchmark
diff --git a/eng/Library.targets b/eng/Library.targets
index 64004df8f31..b09e5c2a93a 100644
--- a/eng/Library.targets
+++ b/eng/Library.targets
@@ -14,6 +14,7 @@
true
+
8.1.0
diff --git a/src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs b/src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs
index 8e71fb79c7a..73fc1010629 100644
--- a/src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs
+++ b/src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs
@@ -254,10 +254,14 @@ private static bool IsDateTimeOverflow(DateTimeOffset utcNow, TimeSpan breakDura
private void EnsureNotDisposed()
{
+#if NET8_0_OR_GREATER
+ ObjectDisposedException.ThrowIf(_disposed, this);
+#else
if (_disposed)
{
throw new ObjectDisposedException(nameof(CircuitStateController));
}
+#endif
}
private void CloseCircuit_NeedsLock(Outcome outcome, bool manual, ResilienceContext context, out Task? scheduledTask)
diff --git a/src/Polly.Core/CircuitBreaker/Controller/ScheduledTaskExecutor.cs b/src/Polly.Core/CircuitBreaker/Controller/ScheduledTaskExecutor.cs
index b3b7cc530ef..7bc3f6f6d5f 100644
--- a/src/Polly.Core/CircuitBreaker/Controller/ScheduledTaskExecutor.cs
+++ b/src/Polly.Core/CircuitBreaker/Controller/ScheduledTaskExecutor.cs
@@ -17,10 +17,14 @@ internal sealed class ScheduledTaskExecutor : IDisposable
public void ScheduleTask(Func taskFactory, ResilienceContext context, out Task task)
{
+#if NET8_0_OR_GREATER
+ ObjectDisposedException.ThrowIf(_disposed, this);
+#else
if (_disposed)
{
throw new ObjectDisposedException(nameof(ScheduledTaskExecutor));
}
+#endif
var source = new TaskCompletionSource