From c68e56dbcf062f43e1084abb5b951783384819cf Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Mon, 2 Mar 2026 11:50:39 +0300 Subject: [PATCH] [dotnet] [bidi] Add disposed guard --- dotnet/src/webdriver/BiDi/BiDi.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dotnet/src/webdriver/BiDi/BiDi.cs b/dotnet/src/webdriver/BiDi/BiDi.cs index e6933b933e660..f008d32a9394f 100644 --- a/dotnet/src/webdriver/BiDi/BiDi.cs +++ b/dotnet/src/webdriver/BiDi/BiDi.cs @@ -27,6 +27,7 @@ namespace OpenQA.Selenium.BiDi; public sealed class BiDi : IBiDi { private readonly ConcurrentDictionary _modules = new(); + private bool _disposed; private Broker Broker { get; set; } = null!; @@ -83,6 +84,13 @@ public Task EndAsync(EndOptions? options = null, CancellationToken ca public async ValueTask DisposeAsync() { + if (_disposed) + { + return; + } + + _disposed = true; + await Broker.DisposeAsync().ConfigureAwait(false); GC.SuppressFinalize(this); }