本文介绍了InvokeAsync秩序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不同的情况下,比,因此另外一个问题。

I have different scenario, than in this question, therefore another question.

让我们以下面的例子:

void PerformanceCriticalMethod()
{
    Dispatcher.Invoke(() => Log.Add("1"));
    ... some job
    Dispatcher.Invoke(() => Log.Add("2"));
}



调用创建性能问题。在试图解决它,我在调用,它的似乎工作的中使用 InvokeAsync ,但它是什么 2 将输出的是非常重要的后 1

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.

我可以依靠的假设,如果两个 InvokeAsync 从他们将以相同的顺序执行同一个线程叫什么? 。为链接我的一个的 WINAPI的螺母的告诉我,这是真的,但我想肯定

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.

和另外一个相关的问题是一样的:如果同样的方法从不同的线程通过 InvokeAsync 被称为动作,多么好机会,有它第一次执行线程谁调用 InvokeAsync 更早?

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?

PS:我觉得问题应该被改写InvokeAsync如何工作,但秩序可能是什么人(包括我在内)100%的候选人将尝试搜索。

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.

推荐答案

请,检查了这一点的

当你调用InvokeAsync,操作放置到PriorityQueue的,所以我想,如果你调用优先级相同的几个动作,你可以相信,这些行动将用相同的顺序来执行。

When you call InvokeAsync, an operation is put to PriorityQueue, so I suppose if you call several actions with the same priority, you can be confident that these actions will be executed with the same order.

这篇关于InvokeAsync秩序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:43