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

Parallelizing database access


So far, we have been splitting work into multiple, independent jobs, and then we used a pool of threads to parallelize I/O operations without great effort. However, a database server is already very well prepared for parallelized access, as it is designed for serving a number of concurrent users. How can we optimize our client applications to take advantage of both multithreading and parallelized database access?

The answer is simple; it depends on the kind of application we need:

  • If we need to optimize something that runs like a time-consuming batch process, we will use specialized subclasses of our well-known ParallelAlgorithmPiece and ParallelAlgorithm classes to develop a new algorithm for parallelizing database access and collecting results.

  • If we need to dispatch many concurrent independent jobs, we will use a pool of threads provided by the ThreadPool class, combined with an independent class, to run the code for each thread.

Tip

As database servers are...