diff --git a/src/HotChocolate/Core/src/Fetching/BatchScheduler.cs b/src/HotChocolate/Core/src/Fetching/BatchScheduler.cs index 697ee30453b..5fc912688f5 100644 --- a/src/HotChocolate/Core/src/Fetching/BatchScheduler.cs +++ b/src/HotChocolate/Core/src/Fetching/BatchScheduler.cs @@ -17,6 +17,7 @@ public sealed class BatchScheduler : IBatchHandler private readonly List> _tasks = []; private bool _dispatchOnSchedule; private readonly List _listeners = []; + private bool _disposed; /// public event EventHandler TaskEnqueued @@ -219,4 +220,13 @@ private async Task DispatchOnEnqueue(Func dispatch) _semaphore.Release(); } } + + public void Dispose() + { + if (!_disposed) + { + _semaphore.Dispose(); + _disposed = true; + } + } } diff --git a/src/HotChocolate/Core/src/Fetching/IBatchHandler.cs b/src/HotChocolate/Core/src/Fetching/IBatchHandler.cs index 43bd1161d26..a45bc5cbf25 100644 --- a/src/HotChocolate/Core/src/Fetching/IBatchHandler.cs +++ b/src/HotChocolate/Core/src/Fetching/IBatchHandler.cs @@ -5,4 +5,4 @@ namespace HotChocolate.Fetching; /// /// The execution engine batch scheduler and dispatcher. /// -public interface IBatchHandler : IBatchDispatcher, IBatchScheduler; +public interface IBatchHandler : IBatchDispatcher, IBatchScheduler, IDisposable;