Snackbar Presenter throws an error when it is unloaded.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Hello
Hello, I've identified a bug during my use of the Snackbar presenter. I haven't fully understood why yet, but when I navigate from one page to another with a Snackbar presenter, an error is thrown because of this event handler: System.ObjectDisposedException: 'The CancellationTokenSource has been disposed.'
After some research, it might be due to this:
protected virtual void OnUnloaded()
{
CancellationTokenSource.Cancel();
CancellationTokenSource.Dispose();
}
So, I created a new class inheriting from the Snackbar presenter but overriding this event handler, and the error no longer appears.
To Reproduce
Steps to recreate the bug:
- Create a Page A without Snackbar Presenter.
- Create a Page B with Snackbar Presenter.
Once the app is launched:
3. Navigate to Page B.
4. Return to Page A.
5. Then navigate again to Page B.
Expected behavior
Correct this x)
Screenshots
No response
OS version
Windows 11
.NET version
8.0
WPF-UI NuGet version
3.0
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Snackbar presenter and inspect the protected OnUnloaded method shown in the report, then reproduce the Page A → Page B → Page A → Page B navigation sequence on Windows with .NET 8. Done means navigating away from and back to the page no longer throws the CancellationTokenSource ObjectDisposedException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100