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

Time for action - Using a generic method in order to create pieces

Creating the pieces and assigning the first and the last element numbers that correspond to each one is a complex task. We want it to be a generic algorithm to help us in focusing on the parallelization process, and not on the splitting problem.

Now, we are going to add some methods to the ParallelAlgorithmPiece class to simplify the splitting assignment:

  1. Stay in the project, OldStarsFinder.
  2. Add the following static function to return a list of ParallelAlgorithmPiece instances:
    public static List<ParallelAlgorithmPiece> CreatePieces(long priTotalElements, int priTotalParts) { // Always starts in element #0 long liPieceSize; List<ParallelAlgorithmPiece> lloPieces; int i; long liTotalCovered ...

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