diff --git a/src/Extensions/DataGrid.EntityFrameworkAdapter/EntityFrameworkAsyncQueryExecutor.cs b/src/Extensions/DataGrid.EntityFrameworkAdapter/EntityFrameworkAsyncQueryExecutor.cs index d76546e1a1..614abccad4 100644 --- a/src/Extensions/DataGrid.EntityFrameworkAdapter/EntityFrameworkAsyncQueryExecutor.cs +++ b/src/Extensions/DataGrid.EntityFrameworkAdapter/EntityFrameworkAsyncQueryExecutor.cs @@ -19,15 +19,22 @@ public Task ToArrayAsync(IQueryable queryable, CancellationToken canc private async Task ExecuteAsync(Func> operation) { - await _lock.WaitAsync(); - try { - return await operation(); + await _lock.WaitAsync(); + + try + { + return await operation(); + } + finally + { + _lock.Release(); + } } - finally + catch (ObjectDisposedException) { - _lock.Release(); + return default!; } }