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

Updating the UI from independent threads


So far, we have been working with parallelized algorithms splitting jobs into pieces, job dispatchers using pools of threads, and C# programming language object-oriented capabilities applied to concurrency. The BackgroundWorker component was always there to help us in providing feedback to the user interface. However, using loops in the BackgroundWorker to synchronize the changes in the threads to update the user interface is annoying. Some applications need to update the user interface at specific times known by the independent threads, which are unable to make direct changes to the UI controls. How can we make changes to the user interface from any independent thread without causing problems and without using BackgroundWorker loops? Is it possible to do that?

Yes, and it is very simple to do that for any independent thread. It doesn't matter if it was created as a new Thread instance or as a worker thread in the ThreadPool class.

Note

There are many...