Ejemplo n.º 1
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop with thread-local data in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// loop options can be configured,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <typeparam name="TLocal">The type of the thread-local data.</typeparam>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="parallelOptions">An object that configures the behavior of this operation.</param>
 /// <param name="localInit">The function delegate that returns the initial state of the local data for each task.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <param name="localFinally">The delegate that performs a final action on the local state of each task.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For <TLocal>(int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Func <TLocal> localInit, Func <int, ParallelLoopState, TLocal, TLocal> body, Action <TLocal> localFinally) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, parallelOptions, localInit, body, localFinally) :
     Sequential.For(fromInclusive, toExclusive, parallelOptions, localInit, body, localFinally);
Ejemplo n.º 2
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop with 64-bit indexes and thread-local data in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <typeparam name="TLocal">The type of the thread-local data.</typeparam>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="localInit">The function delegate that returns the initial state of the local data for each task.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <param name="localFinally">The delegate that performs a final action on the local state of each task.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For <TLocal>(long fromInclusive, long toExclusive, Func <TLocal> localInit, Func <long, ParallelLoopState, TLocal, TLocal> body, Action <TLocal> localFinally) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, localInit, body, localFinally) :
     Sequential.For(fromInclusive, toExclusive, localInit, body, localFinally);
Ejemplo n.º 3
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop with 64-bit indexes in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// loop options can be configured,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="parallelOptions">An object that configures the behavior of this operation.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For(long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action <long, ParallelLoopState> body) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, parallelOptions, body) :
     Sequential.For(fromInclusive, toExclusive, parallelOptions, body);
Ejemplo n.º 4
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For(int fromInclusive, int toExclusive, Action <int, ParallelLoopState> body) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, body) :
     Sequential.For(fromInclusive, toExclusive, body);
Ejemplo n.º 5
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// and loop options can be configured.
 /// </summary>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="parallelOptions">An object that configures the behavior of this operation.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For(int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Action <int> body) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, parallelOptions, body) :
     Sequential.For(fromInclusive, toExclusive, parallelOptions, body);
Ejemplo n.º 6
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop with 64-bit indexes in which iterations are run sequentially when the debugger is attached or in parallel otherwise.
 /// </summary>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For(long fromInclusive, long toExclusive, Action <long> body) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, body) :
     Sequential.For(fromInclusive, toExclusive, body);