lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.47k stars 725 forks source link

Fix: SnackbarPresenter might throw ObjectDisposedException, display problems. #1138

Closed textGamex closed 2 months ago

textGamex commented 3 months ago

Pull request type

Please check the type of change your PR introduces:

What is the current behavior?

Issue Number: Snackbar Presenter throws an error when it is unloaded. #951

What is the new behavior?

The CancellationTokenSource will no longer be disposed within the OnUnloaded method; rather, its disposal will be deferred to the class's finalizer. Additionally, invoking the OnUnloaded method will promptly trigger the hiding of the Snackbar.

I'm unsure if there's a better approach to properly dispose the CancellationTokenSource, as relying on the finalizer could result in untimely disposal due to the inherent unpredictability of garbage collection.