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 - Collecting the garbage at the right time

The NASA scientists are waiting for you to solve the problem. They bring you a cappuccino, but then it reminds you of your exhausting work with the FBI agents. You prefer an orange juice!

Now, we are going to force the garbage collection service to free unused resources before running the algorithm on each image. This way, the memory consumption will not increase after each image is processed, and we will avoid the possibility of the garbage collection service being executed automatically in the middle of the intensive multithreaded code:

  1. Stay in the project, OldStarsFinder.
  2. Add the following line before the for (liThreadNumber = 0; liThreadNumber < priProcessorCount; liThreadNumber++)

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