Skip to content

"The current thread is not associated with the Dispatcher" with OnInitializedAsync() #569

Answered by egil
samcarswell asked this question in Q&A
Discussion options

You must be logged in to vote

... However I get the following error when await Task.Run(StateHasChanged); is called in OnInitializedAsync() of FilterTable:

If I understand correctly what you are writing, then you need to wrap your call to StateHasChanged into an InvokeAsync call in your component. E.g.:

Task.Run(InvokeAsync(StateHasChanged));`

However, if you have the code you list above, then you are likely doing something unusual in Blazor. I cannot think of a reason why you would call StateHasChanged from a new task you manually create with Task.Run.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@samcarswell
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by samcarswell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants