|
using System;
using Amib.Threading;
namespace Examples
{
public class SimpleExample
{
public void DoWork(int[] numbers)
{
SmartThreadPool smartThreadPool = new SmartThreadPool();
// Queue the work item
IWorkItemResult<double> wir = smartThreadPool.QueueWorkItem(new Func<int[], double>(CalcAverage), numbers);
// Do some other work here
// Get the result of the operation
double average = wir.Result;
smartThreadPool.Shutdown();
}
// Do the real work
private double CalcAverage(int[] numbers)
{
double average = 0.0;
// Do the real work here and put
// the result in 'result'
return average;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
B.Sc. in Computer Science.
Works as Software Developer.