bugthesystem / FireSharp

An asynchronous cross-platform .Net library for Firebase
The Unlicense
690 stars 146 forks source link

response.Dispose() doesn't stop listening to event for OnAsync() #156

Open SergueiRazykov opened 3 years ago

SergueiRazykov commented 3 years ago

We call Dispose() method when trying to re-connect but it doesn't stop the listening to events

        try
        {
            if (_fbOnAsyncResponse != null)
            {
                _fbOnAsyncResponse.Dispose();
            }
        }
        catch (Exception ex)
        {
            this.Log().Warn($"Failed to dispose {ex.Message}");
            //no-op//
        }

        _fbOnAsyncResponse = await _firebaseClient.OnAsync(path,
            added: async (s, args, d) =>
            {

......

After it is called a few times, the event is processed by a few threads the same time. Version FireSharp 2.0.4

maltezc commented 3 years ago

@SergueiRazykov I just ran into this issue. now when I make adjustments on my web app, it affects my c# winforms app startup.

Any luck on figuring this out?

I've tried .Dispose() and .Cancel() and neither work.

SergueiRazykov commented 3 years ago

@maltezc Unfortunately, no. I looked at the code and believe that Dispose() includes Cancel(), still not working. I stopped useing these methods altogether, Just re-starting the app when I am losing connection.