melihercan / WebRTCme

A cross-platform framework for adding WebRTC support to .NET MAUI, Blazor, and Desktop applications by using a single unified .NET/C# API.
https://github.com/melihercan/WebRTCme
MIT License
226 stars 46 forks source link

Suggestion: IAsyncDisposable #17

Open Psypher9 opened 2 years ago

Psypher9 commented 2 years ago

Hello! I noticed a few of the comments in the demo app here and also on the CallPage.razor.cs.

        public void Dispose()
        {
            Task.Run(async () => await ChatViewModel.OnPageDisappearingAsync());

            //// TODO: How to call async in Dispose??? Currently fire and forget!!!
            //Task.Run(async () => await _signallingServerService.DisposeAsync());
            //_webRtcMiddleware.Dispose();
        }

You may have already dealt with it by now, but I think for this use-case using the IAsyncDisposable interface should get you what you need and may be helpful for documentation.

I'm happy to make a PR for this, just wanted to contribute my thoughts on this.

melihercan commented 2 years ago

Hi @Psypher9 and thanks for the suggestion.

I can't remember the exact details right now but I remember considering IAsyncDisposable in this case but I didn't. Perhaps ChatPage is a Blazor page and it does not support/call IAsyncDisposable (only IDisposable, at least at that time).

As I mentioned on other topics, I have no time to spend on this project right now, so if you think this can be done please issue a PR.