diff --git a/WalletConnectSharp.Core/Controllers/Relayer.cs b/WalletConnectSharp.Core/Controllers/Relayer.cs index 219fa8d..62e6aa7 100644 --- a/WalletConnectSharp.Core/Controllers/Relayer.cs +++ b/WalletConnectSharp.Core/Controllers/Relayer.cs @@ -230,13 +230,15 @@ protected virtual void RegisterProviderEventListeners() protected virtual void RegisterEventListeners() { - this.OnConnectionStalled += async (sender, args) => - { - if (this.Provider.Connection.IsPaused) - return; + this.OnConnectionStalled += OnConnectionStalledHandler; + } - await this.RestartTransport(); - }; + private async void OnConnectionStalledHandler(object sender, EventArgs e) + { + if (this.Provider.Connection.IsPaused) + return; + + await this.RestartTransport(); } protected virtual async void OnProviderPayload(string payloadJson) @@ -499,6 +501,9 @@ protected virtual void Dispose(bool disposing) if (disposing) { + _transportExplicitlyClosed = true; + this.OnConnectionStalled -= OnConnectionStalledHandler; + Subscriber?.Dispose(); Publisher?.Dispose(); Messages?.Dispose();