O'Reilly logo

C# 2008 and 2005 Threaded Programming: Beginner's Guide by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming the piece creation method

We had to override the CreateParallelAlgorithmPiece method. This method will create the appropriate instance of a ParallelAlgorithmPiece subclass:

public override ParallelAlgorithmPiece CreateParallelAlgorithmPiece(int priThreadNumber)
{
return (new SunspotAnalyzerPiece(priThreadNumber));
}

It returns a new SunspotAnalyzerPiece instance, sending the thread or piece number as a parameter.

Overriding this method, we can return instances of the SunspotAnalyzerPiece class (a subclass of ParallelAlgorithmPiece).

Programming the results collection method

We also had to override the CollectResults method. This method will collect the results left in each SunspotAnalyzerPiece subclass instance.

We already know the mechanism, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required