How should I invoke code on main thread? #10034
Answered
by
jeromelaban
jeromelaban
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
jeromelaban
Oct 3, 2022
Replies: 1 comment
-
You can use the DispatcherQueue API, this answer from stack overflow sums it up pretty well. In short, you need to get a |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jeromelaban
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 theTryEnqueue
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 theDispatcherQueue
to use there.