Search Wiki:
Resource Page Description
While waiting for Parallel Extensions, that will be shipped with next .Net Framework release, I designed a couple of class that allow to quickly (and easily!) write code that make use of multi-threading and, therefore, speed-up many tasks. What I show here is a simple class able to collect pieces of code (in form of delegate) to be executed concurrently, and parallelize and synchronize the execution.

Basically a small (but powerful) set of classes that make you able to take a piece of code like this:
 
void SerialExecution()
{
    Uri uri; int value;
 
    CallWebService(uri);
    PerformComputation(value);
}

and change it into:
 
void ParallelExecution
{
  Uri uri; int value;
 
  ParallelExecutor executor = new ParallelExecutor();
 
  IExecutionInfo<int> execution = executor.Add<Uri, int>(CallWebService, uri);
  executor.Add(PerformComputation, value);
 
  executor.WaitAll();
 
  if (execution.Exception != null)
      ManageException(execution.Exception);
  else
      Console.WriteLine("Result: {0}", execution.Result);
}

Full intro here
Last edited May 18 at 11:15 PM  by MatteoSp, version 3
Updating...
Page view tracker