From 08445970d5dd91a52e594f1feaf7b99f09dc4a02 Mon Sep 17 00:00:00 2001 From: Miguel Hasse de Oliveira Date: Wed, 9 Oct 2024 06:41:37 +0100 Subject: [PATCH] Fix for reported issue #2769 (#2781) --- .../EntityFrameworkAsyncQueryExecutor.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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!; } }