Skip to content

How should I invoke code on main thread? #10034

Answered by jeromelaban
jeromelaban asked this question in Q&A
Discussion options

You must be logged in to vote

You can use the DispatcherQueue API, this answer from stack overflow sums it up pretty well.

In short, you need to get a DispatcherQueue instance, then use the TryEnqueue method. If you're in a control's code behind, DispatcherQueue is readily accessible, but if you're somewhere else, like in a ViewModel, you'll need to capture the DispatcherQueue to use there.

Replies: 1 comment

Comment options

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