Book Image

C# 2008 and 2005 Threaded Programming: Beginner's Guide

By : Gaston C. Hillar
Book Image

C# 2008 and 2005 Threaded Programming: Beginner's Guide

By: Gaston C. Hillar

Overview of this book

<p>Most modern machines have dual core processors. This means that multitasking is built right into your computer's hardware. Using both cores means your applications can process data faster and be more responsive to users. But to fully exploit this in your applications, you need to write multithreading code, which means learning some challenging new concepts.<br /><br />This book will guide you through everything you need to start writing multithreaded C# applications. You will see how to use processes and threads in C#, .NET Framework features for concurrent programming, sharing memory space between threads, and much more. The book is full of practical, interesting examples and working code.<br /><br />This book begins with the fundamental concepts such as processes, threads, mono-processor systems, multi-processor systems. As the book progresses, the readers get a clear understanding of starting, joining, pausing and restarting threads. The readers get a better understanding of the simple techniques associated with parallelism. There are short exercises at the end of every chapter for the readers to perform.<br /><br />The book also includes several practical parallelism algorithms and data structures used for illustration, and best practices and practical topics like debugging and performance.</p>
Table of Contents (19 chapters)
C# 2008 and 2005 Threaded Programming
Credits
About the Author
Acknowledgement
About the Reviewers
Preface
Index

Running split jobs many times


So far, we have developed applications applying innovative algorithms to generate separate portions from a huge piece and used them to create very independent blocks of code to be run in multiple threads. We achieved a great performance improvement and a better UI feedback while avoiding classic concurrency problems. However, we have been working with algorithms running just once. How can we have performance improvements achieved while running the split jobs many times, and in different situations?

C# safe code (managed code) uses a service that automatically reclaims unused memory. It is known as the system garbage collector. This way, programmers do not have to worry about freeing resources used by the different objects and data types—making the developer's life easier. However, when we split jobs into many concurrent threads, and we do that repeatedly, many times over, the garbage could create some trouble and degrade our applications' performance.

Working...