From 52a88fa76c17f9c32cb89980b43f7d137e0cd66c Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Fri, 7 Feb 2025 20:27:56 +0330 Subject: [PATCH] fix ObjectDisposedException in BitCarousel #9821 --- .../Components/Lists/Carousel/BitCarousel.razor.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cs b/src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cs index 1f77649461..193ba8b3c7 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Lists/Carousel/BitCarousel.razor.cs @@ -284,6 +284,7 @@ private async Task Next() private async Task Go(bool isNext = false, int scrollCount = 0) { + if (_disposed) return; if (_othersIndices.Length == 0) return; if (scrollCount < 1) @@ -432,6 +433,8 @@ protected virtual async ValueTask DisposeAsync(bool disposing) { if (_disposed || disposing is false) return; + _disposed = true; + if (_autoPlayTimer is not null) { _autoPlayTimer.Elapsed -= AutoPlayTimerElapsed; @@ -447,7 +450,5 @@ protected virtual async ValueTask DisposeAsync(bool disposing) } catch (JSDisconnectedException) { } // we can ignore this exception here } - - _disposed = true; } }