Reputation: 12119
Given this code:
Task.Factory.StartNew(() =>
{
Application.Current.Dispatcher.Invoke(() =>
{
//UI Code 1
});
//Non UI Code
taskResult = SomeMethod();
Application.Current.Dispatcher.Invoke(() =>
{
//UI Code 2
if (taskResult)...
});
});
Is UI Code 2
executed after the Non UI Code
is finished with execution or does it execute while Non UI Code
is still running?
In other words, is it safe to assume that taskResult variable will always have the results of Non-UI thread processing when called within UI Code 2
block?
Upvotes: 0
Views: 184
Reputation: 3990
Given MSDN description for Dispatcher.Invoke
:
Executes the specified delegate synchronously on the thread the Dispatcher is associated with.
The answer to your question is Yes.
Upvotes: 1