PageAsyncTask.ExecuteInParallel 属性
定义
获取一个值,该值指示任务能否与其他任务并行处理。Gets a value that indicates whether the task can be processed in parallel with other tasks.
public:
property bool ExecuteInParallel { bool get(); };
public bool ExecuteInParallel { get; }
member this.ExecuteInParallel : bool
Public ReadOnly Property ExecuteInParallel As Boolean
属性值
如果任务应当与其他任务并行处理,则为 true;否则为 false。true if the task should be processed in parallel with other tasks; otherwise, false.
示例
下面的代码示例定义了三个异步任务,每个任务都是并行处理的。The following code example defines three asynchronous tasks that are each set to be processed in parallel. 此示例摘自类概述中的一个更大的示例 PageAsyncTask 。This example is part of a larger example found in the PageAsyncTask class overview.
PageAsyncTask asyncTask1 = new PageAsyncTask(slowTask1.OnBegin, slowTask1.OnEnd, slowTask1.OnTimeout, "Async1", true);
PageAsyncTask asyncTask2 = new PageAsyncTask(slowTask2.OnBegin, slowTask2.OnEnd, slowTask2.OnTimeout, "Async2", true);
PageAsyncTask asyncTask3 = new PageAsyncTask(slowTask3.OnBegin, slowTask3.OnEnd, slowTask3.OnTimeout, "Async3", true);
// Register the asynchronous task.
Page.RegisterAsyncTask(asyncTask1);
Page.RegisterAsyncTask(asyncTask2);
Page.RegisterAsyncTask(asyncTask3);
Dim asyncTask1 As New PageAsyncTask(AddressOf slowTask1.OnBegin, AddressOf slowTask1.OnEnd, AddressOf slowTask1.OnTimeout, "Async1", True)
Dim asyncTask2 As New PageAsyncTask(AddressOf slowTask2.OnBegin, AddressOf slowTask2.OnEnd, AddressOf slowTask2.OnTimeout, "Async2", True)
Dim asyncTask3 As New PageAsyncTask(AddressOf slowTask3.OnBegin, AddressOf slowTask3.OnEnd, AddressOf slowTask3.OnTimeout, "Async3", True)
' Register the asynchronous task.
Page.RegisterAsyncTask(asyncTask1)
Page.RegisterAsyncTask(asyncTask2)
Page.RegisterAsyncTask(asyncTask3)
注解
在 ExecuteInParallel 构造函数中设置属性。The ExecuteInParallel property is set in the constructor. 如果在页中注册了多个任务,并将 ExecuteInParallel 属性设置为 true ,则会同时处理这些任务。When multiple tasks are registered in a page and the ExecuteInParallel property is set to true, then those tasks are processed concurrently. 但是,如果将 ExecuteInParallel 属性设置为 false ,则会按顺序处理这些任务。However, if the ExecuteInParallel property is set to false, then those tasks are processed sequentially. 例如,如果某个页面包含两个异步任务,每个任务都需要5秒才能完成,并且 ExecuteInParallel 设置为 true ,则这两个任务将在5秒内完成。For example, if a page contained two asynchronous tasks that each took 5 seconds to complete and ExecuteInParallel is set to true, both tasks will complete in 5 seconds. 如果 ExecuteInParallel 将 false 这两个任务的设置为,则第一个任务将在5秒内完成,第二个任务将在第一个任务完成5秒后完成。If ExecuteInParallel is set to false for these same two tasks, then the first task will complete in 5 seconds and the second task will complete 5 seconds after the completion of the first task.