You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When you use the ToatService after an asynchronous operation an InvalidOperationException is throwed: System.InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.. The Toast that should be created using the ToastService appears as expected but with the exception.
It is possible to fix this issue if you wrap the ToastService call in a InvokeAsync(() => { }) call but it would be nice if I don't have to do this on every ToastService call.
To Reproduce
Create a Blazor Server application
Use interactive server as global rendermode
Add in the App.razor or somewere else the Toasts component with the interactive server rendermode.
In any page inject the ToastService
Add a button to this page that performs on click an asynchronous operation and after this the ToastService should notify the user (I'am not sure why but not every async operation causes this issue. In my case often at Db queries).
Expected behavior
Using the ToastService after async operation without the risk of throwing an exception.
Versions:
.NET Version: .NET 8
BlazorBootstrap: 3.0.0-preview-3
Blazor WebAssembly / Server: Server
Blazor Interactive Render Mode: Interactive Server
Blazor Interactivity Location: Global
Desktop:
OS: Windows 11
Browser Chrome
Smartphone: Not tested on mobile device because it's a server-side issue.
The text was updated successfully, but these errors were encountered:
Suiram1701
added a commit
to Suiram1701/blazorbootstrap
that referenced
this issue
Aug 14, 2024
Describe the bug
When you use the ToatService after an asynchronous operation an InvalidOperationException is throwed:
System.InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
. The Toast that should be created using the ToastService appears as expected but with the exception.It is possible to fix this issue if you wrap the ToastService call in a
InvokeAsync(() => { })
call but it would be nice if I don't have to do this on every ToastService call.To Reproduce
Expected behavior
Using the ToastService after async operation without the risk of throwing an exception.
Versions:
Desktop:
Smartphone: Not tested on mobile device because it's a server-side issue.
The text was updated successfully, but these errors were encountered: