The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state. #456
Unanswered
Chandradev819
asked this question in
Q&A
Replies: 1 comment
-
This is an exception thrown by Blazor. My best guess from reading the code is that you need to change this method like so: private void HandleClockTimeUpdate(Object source, System.Timers.ElapsedEventArgs e)
{
var latestTime = DateTime.Now;
if ((int)latestTime.TimeOfDay.TotalMinutes > (int)ClockDateTime.TimeOfDay.TotalMinutes)
{
ClockDateTime = latestTime;
InvokeAsync(() => StateHasChanged());
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to implement the Bunit in my project. But i m getting below exception.
"The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state."
Login Page Code behind C# Code
namespaceDNA.Touch.Client.Pages.Auth
{
public class LoginBase : ComponentBase, IDisposable
{
#region DI Services
[Inject] private IToastService ToastService { get; set; }
[Inject] private NavigationManager NavigationManager { get; set; }
[Inject] private ILocalStorageService StorageService { get; set; }
[Inject] private AuthenticationStateProvider AuthenticationStateProvider { get; set; }
}
Bunit Test Case
Beta Was this translation helpful? Give feedback.
All reactions