Parallel Osztály
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Támogatja a párhuzamos hurkokat és régiókat.
public ref class Parallel abstract sealed
public static class Parallel
type Parallel = class
Public Class Parallel
- Öröklődés
-
Parallel
Példák
Ez a példa több módszert mutat be egy párhuzamos hurok több nyelvi szerkezettel történő implementálásához.
using System.Threading.Tasks;
class Test
{
static int N = 1000;
static void TestMethod()
{
// Using a named method.
Parallel.For(0, N, Method2);
// Using an anonymous method.
Parallel.For(0, N, delegate(int i)
{
// Do Work.
});
// Using a lambda expression.
Parallel.For(0, N, i =>
{
// Do Work.
});
}
static void Method2(int i)
{
// Do work.
}
}
Imports System.Threading.Tasks
Module Module1
Sub Main()
Dim N As Integer = 1000
' Using a named method
Parallel.For(0, N, AddressOf Method2)
' Using a lambda expression.
Parallel.For(0, N, Sub(i)
' Do Work
End Sub)
End Sub
Sub Method2(ByVal i As Integer)
' Do work.
End Sub
End Module
Megjegyzések
Az Parallel osztály könyvtáralapú párhuzamos adatcseréket biztosít a gyakori műveletekhez, például a hurkokhoz, az egyes hurkokhoz és egy utasításkészlet végrehajtásához.
Metódusok
| Name | Description |
|---|---|
| For(Int32, Int32, Action<Int32,ParallelLoopState>) |
Olyan ciklust |
| For(Int32, Int32, Action<Int32>) |
Olyan ciklust |
| For(Int32, Int32, ParallelOptions, Action<Int32,ParallelLoopState>) |
Olyan ciklust |
| For(Int32, Int32, ParallelOptions, Action<Int32>) |
Végrehajt egy ciklust |
| For(Int64, Int64, Action<Int64,ParallelLoopState>) |
Egy 64 bites indexekkel rendelkező ciklust |
| For(Int64, Int64, Action<Int64>) |
Egy ciklust |
| For(Int64, Int64, ParallelOptions, Action<Int64,ParallelLoopState>) |
Egy 64 bites indexekkel rendelkező ciklust |
| For(Int64, Int64, ParallelOptions, Action<Int64>) |
|
| For<TLocal>(Int32, Int32, Func<TLocal>, Func<Int32,ParallelLoopState,TLocal,TLocal>, Action<TLocal>) |
Egy szálalapú adatokkal rendelkező hurkot |
| For<TLocal>(Int32, Int32, ParallelOptions, Func<TLocal>, Func<Int32,ParallelLoopState,TLocal,TLocal>, Action<TLocal>) |
Olyan ciklust |
| For<TLocal>(Int64, Int64, Func<TLocal>, Func<Int64,ParallelLoopState,TLocal,TLocal>, Action<TLocal>) |
Egy ciklust |
| For<TLocal>(Int64, Int64, ParallelOptions, Func<TLocal>, Func<Int64,ParallelLoopState,TLocal,TLocal>, Action<TLocal>) |
|
| ForEach<TSource,TLocal>(IEnumerable<TSource>, Func<TLocal>, Func<TSource,ParallelLoopState,Int64,TLocal,TLocal>, Action<TLocal>) |
Végrehajt egy |
| ForEach<TSource,TLocal>(IEnumerable<TSource>, Func<TLocal>, Func<TSource,ParallelLoopState,TLocal,TLocal>, Action<TLocal>) |
Végrehajt egy |
| ForEach<TSource,TLocal>(IEnumerable<TSource>, ParallelOptions, Func<TLocal>, Func<TSource,ParallelLoopState,Int64,TLocal,TLocal>, Action<TLocal>) |
Egy |
| ForEach<TSource,TLocal>(IEnumerable<TSource>, ParallelOptions, Func<TLocal>, Func<TSource,ParallelLoopState,TLocal,TLocal>, Action<TLocal>) |
Végrehajt egy |
| ForEach<TSource,TLocal>(OrderablePartitioner<TSource>, Func<TLocal>, Func<TSource,ParallelLoopState,Int64,TLocal,TLocal>, Action<TLocal>) |
Egy |
| ForEach<TSource,TLocal>(OrderablePartitioner<TSource>, ParallelOptions, Func<TLocal>, Func<TSource,ParallelLoopState,Int64,TLocal,TLocal>, Action<TLocal>) |
Egy |
| ForEach<TSource,TLocal>(Partitioner<TSource>, Func<TLocal>, Func<TSource,ParallelLoopState,TLocal,TLocal>, Action<TLocal>) |
Egy |
| ForEach<TSource,TLocal>(Partitioner<TSource>, ParallelOptions, Func<TLocal>, Func<TSource,ParallelLoopState,TLocal,TLocal>, Action<TLocal>) |
Egy |
| ForEach<TSource>(IEnumerable<TSource>, Action<TSource,ParallelLoopState,Int64>) |
Végrehajt egy |
| ForEach<TSource>(IEnumerable<TSource>, Action<TSource,ParallelLoopState>) |
Végrehajt egy |
| ForEach<TSource>(IEnumerable<TSource>, Action<TSource>) |
Végrehajt egy |
| ForEach<TSource>(IEnumerable<TSource>, ParallelOptions, Action<TSource,ParallelLoopState,Int64>) |
Végrehajt egy |
| ForEach<TSource>(IEnumerable<TSource>, ParallelOptions, Action<TSource,ParallelLoopState>) |
Egy |
| ForEach<TSource>(IEnumerable<TSource>, ParallelOptions, Action<TSource>) |
Végrehajt egy |
| ForEach<TSource>(OrderablePartitioner<TSource>, Action<TSource,ParallelLoopState,Int64>) |
Végrehajt egy |
| ForEach<TSource>(OrderablePartitioner<TSource>, ParallelOptions, Action<TSource,ParallelLoopState,Int64>) |
Végrehajt egy |
| ForEach<TSource>(Partitioner<TSource>, Action<TSource,ParallelLoopState>) |
Végrehajt egy |
| ForEach<TSource>(Partitioner<TSource>, Action<TSource>) |
Végrehajt egy |
| ForEach<TSource>(Partitioner<TSource>, ParallelOptions, Action<TSource,ParallelLoopState>) |
Végrehajt egy |
| ForEach<TSource>(Partitioner<TSource>, ParallelOptions, Action<TSource>) |
Végrehajt egy |
| Invoke(Action[]) |
Végrehajtja az egyes megadott műveleteket, esetleg párhuzamosan. |
| Invoke(ParallelOptions, Action[]) |
Végrehajtja az egyes megadott műveleteket, esetleg párhuzamosan, kivéve, ha a felhasználó megszakítja a műveletet. |
A következőre érvényes:
Szálbiztonság
Az összes nyilvános és védett tagja Parallel szálbiztos, és egyidejűleg több szálból is használható.