AlphaFramework API
1.0.3
|
A lightweight implementation of a small subset of Microsoft's Parallel Extensions for .Net 3.5/4.0 that can be used with the earlier .Net/C# 2.0 More...
Public Member Functions | |
void | Dispose () |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More... | |
Static Public Member Functions | |
static void | For (int start, int stop, [NotNull, InstantHandle] Action< int > loopBody, CancellationToken cancellationToken=default(CancellationToken)) |
Executes a parallel For loop. More... | |
static void | ForEach< T > (IEnumerable< T > items, [NotNull, InstantHandle] Action< T > loopBody) |
Executes a parallel Foreach loop. More... | |
Protected Member Functions | |
virtual void | Dispose (bool disposing) |
Disposes resources. More... | |
Properties | |
static int? | ThreadsCount [get, set] |
Gets or sets the number of threads used for parallel computations. More... | |
A lightweight implementation of a small subset of Microsoft's Parallel Extensions for .Net 3.5/4.0 that can be used with the earlier .Net/C# 2.0
This is an analogue of "Microsoft Parallel Extensions to .NET Framework 3.5, June 2008 Community Technology Preview" from: http://www.microsoft.com/downloads/details.aspx?FamilyID=348f73fd-593d-4b3c-b055-694c50d2b0f3&DisplayLang=en It is not a full implementation, and should be deprecated when MEDIT switch to Visual Studio 2010/.Net 4.0 by using the Microsoft/Novell Mono equivalents. Mono already supports the Parallel Extensions.
This class supports the Parallel.For and Parallel.ForEach loop constructs.
See also: http://tirania.org/blog/archive/2008/Jul-26-1.html http://blogs.msdn.com/somasegar/archive/2008/06/02/june-2008-ctp-parallel-extensions-to-the-net-fx.aspx
This should work on any version of C#/.Net that supports generics.
|
inlineprotectedvirtual |
Disposes resources.
disposing | if set to true , dispose managed resources. |
|
inline |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
inlinestatic |
Executes a parallel For loop.
start | Loop start index. |
stop | Loop stop index. |
loopBody | Loop body. |
cancellationToken | Used to signal if the user wishes to cancel the loop before it completes. |
The method is used to parallelise for loop by running iterations across several threads. Example usage:
can be replaced by:
If Parallel.ThreadCount
is exactly 1
, no threads are spawned.
|
inlinestatic |
Executes a parallel Foreach loop.
T | type |
items | Loop items. |
loopBody | Loop body. |
The method is used to parallelise for loop by running iterations across several threads. Example usage:
can be replaced by:
If Parallel.ThreadCount
is exactly 1
, no threads are spawned.
|
staticgetset |
Gets or sets the number of threads used for parallel computations.
The threads count.
By default the property is number of CPUs, i.e., System.Environment.ProcessorCount. Setting the property to zero also causes it to be reset to this value.