System::Threading::Tasks::Parallel::ForEach 方法
内容
[
隐藏
]Parallel::ForEach(const SharedPtr<Collections::Generic::IEnumerable<TSource>>&, const Action<TSource>&) method
对 IEnumerable 执行 foreach 操作,其中迭代可以并行运行。
template<typename TSource> static ParallelLoopResult System::Threading::Tasks::Parallel::ForEach(const SharedPtr<Collections::Generic::IEnumerable<TSource>> &source, const Action<TSource> &body)
| 参数 | 描述 |
|---|---|
| TSource | 源中数据的类型。 |
| 参数 | 类型 | 描述 |
|---|---|---|
| 源 | const SharedPtr<Collections::Generic::IEnumerable<TSource>>& | 一个可枚举的数据源。 |
| body | const Action<TSource>& | 每次迭代调用一次的委托。 |
ReturnValue
一个 ParallelLoopResult 结构,包含有关循环已完成部分的信息。
备注
使用默认的 ParallelOptions,具有无限并行度且不支持取消。
另见
- Class ParallelLoopResult
- Typedef SharedPtr
- Class IEnumerable
- Typedef Action
- Class Parallel
- Namespace System::Threading::Tasks
- Library Aspose.Font for C++
Parallel::ForEach(const SharedPtr<Collections::Generic::IEnumerable<TSource>>&, const SharedPtr<ParallelOptions>&, const Action<TSource>&) method
对 IEnumerable 执行 foreach 操作,其中迭代可以并行运行。
template<typename TSource> static ParallelLoopResult System::Threading::Tasks::Parallel::ForEach(const SharedPtr<Collections::Generic::IEnumerable<TSource>> &source, const SharedPtr<ParallelOptions> ¶llelOptions, const Action<TSource> &body)
| 参数 | 描述 |
|---|---|
| TSource | 源中数据的类型。 |
| 参数 | 类型 | 描述 |
|---|---|---|
| 源 | const SharedPtr<Collections::Generic::IEnumerable<TSource>>& | 一个可枚举的数据源。 |
| parallelOptions | const SharedPtr<ParallelOptions>& | 一个配置此操作行为的对象。 |
| body | const Action<TSource>& | 每次迭代调用一次的委托。 |
ReturnValue
一个 ParallelLoopResult 结构,包含有关循环已完成部分的信息。
备注
此方法将源可枚举对象分区,并在多个线程上并发执行 body 委托。
另见
- Class ParallelLoopResult
- Typedef SharedPtr
- Class IEnumerable
- Class ParallelOptions
- Typedef Action
- Class Parallel
- Namespace System::Threading::Tasks
- Library Aspose.Font for C++