I have different scenario, than in this question, therefore another question.
Let's take following example:
void PerformanceCriticalMethod()
{
Dispatcher.Invoke(() => Log.Add("1"));
... some job
Dispatcher.Invoke(() => Log.Add("2"));
}
Invoke
creates performance problems. In attempt to fix it I used InvokeAsync
in place of Invoke
and it seems to work, but it is important what 2
will be output after 1
.
Can I rely on assumption what if two InvokeAsync
are called from same thread they will execute in the same order? My winapi's nut tells me it's true, but I want to be sure.
And another related question is same as linked one: if same method is called via InvokeAsync
action from different threads, how good are chances to have it executed first for thread who calls InvokeAsync
earlier?
P.S.: I have feeling question should be rephrased "How InvokeAsync works", but the word "order" is probably 100% candidate of what people (including me) will try to search for.