| |
| |
|
|
Exploit the power of multiple processors for faster, more responsive software.
- Develop applications that run several tasks simultaneously to achieve greater performance, scalability, and responsiveness in your applications
- Build and run well-designed and scalable applications with C# parallel programming.
- In-depth practical approach to help you become better and faster at managing different processes and threads
- Optimized techniques on parallellized processes for advanced concepts
- Packed with hands-on-examples and clear explanations for better understanding
|
|
- Buy 2 books, get 18% off
- Buy 2 eBooks, get 35% off
|
Code download Request a Review Copy Send us feedback on this title Ask a question about this title
Sample Chapter 8 Simplifying Parallelism Complexity [2.0 MB] Table of Contents
Language English
Paperback 416 pages [191mm x 235mm]
Release date
January 2009
ISBN 1847197108
ISBN 13 978-1-847197-10-8
Author(s)
Gastón C. Hillar
Topics and Technologies
Microsoft & .NET, Beginner Guides
Special eBook Discount Offer |
|
A practical guide to developing responsive multi-threaded and multi-process applications in C#
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.
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.
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.
The book also includes several practical parallelism algorithms and data structures used for illustration, and best practices and practical topics like debugging and performance.
Read the full Table of Contents for C# 2008 and 2005 Threaded Programming: Beginner's Guide
- Transform single-threaded algorithms to multithreaded scalable jobs by using object-oriented capabilities create an independent thread with an asynchronous execution by using a delegate to update the UI
- Achieve responsive user interface using synchronous and asynchronous delegates to dispatch changes to the UI thread
- Specify the degree of parallelism desired for determining the number of threads that the query must use to achieve better performance
- Create applications that use the full power of the processors using parallel programming techniques
- Develop applications to create background threads using the BackgroundWorker component
- Learn debugging techniques to find solutions to multithreaded application problems
Chapter 1: Taking Advantage of Multiprocessing and Multiple Cores Mono-processor systems: The old gladiators Single core: Only one warrior to fight against everybody The performance waterfall Multi-processor systems: Many warriors to win a battle Estimating performance improvements Avoiding bottlenecks Taking advantage of multiple execution cores Scalability Load balancing: Keeping everybody happy Operating systems and virtual machines Parallelism is here to stay Code patterns learned in this chapter Exercises Chapter 2: Processes and Threads What is a process? What is a thread? Multiple threads in servers Multiple threads in clients Code patterns learned in this chapter Exercises Chapter 3: BackgroundWorker in action for beginners RTC: Rapid thread creation Defining the work to be done Asynchronous execution Synchronous execution Showing the progress Canceling the job Working with multiple BackgroundWorker BackgroundWorker vs. Timer BackgroundWorker creation on the fly Code patterns learned in this chapter Exercises Chapter 4: Thread Class—Practical Multithreading in Applications Creating threads with the Thread class Sharing data between threads Passing parameters to threads Code patterns learned in this chapter Exercises Chapter 5: Simple Debugging Techniques with Multithreading Watching multiple threads Debugging multithreaded applications as single-threaded applications Showing partial results in multi threaded code Code patterns learned in this chapter Exercises Chapter 6: Understanding threads’ control with patterns Starting, Joining, Pausing and Restarting threads Understanding the pixels' color compositions Creating independent blocks of concurrent code Using flags to enhance control over concurrent threads Testing results with Performance Monitor and Process Explorer Using the AutoResetEvent class to handle signals between threads Using the WaitHandle class to check for signals Code patterns learned in this chapter Exercises Chapter 7: Dynamically Splitting Jobs into Pieces—Avoiding Problems Running split jobs many times Using classes, methods, procedures, and functions with multithreading capabilities Understanding the garbage collector with multi threading Controlling the system garbage collector with the GC class Avoiding garbage collection problems Avoiding inefficient processing usage problems Retrieving the total memory thought to be allocated Generalizing the algorithms for segmentation with classes Code patterns learned in this chapter Exercises Chapter 8: Simplifying Parallelism Complexity Specializing the algorithms for segmentation with classes Defining the class to instantiate Creating simple constructors Programming the results collection method Optimizing and encapsulati ng parallel algorithms Achieving thread affinity Avoiding locks and many synchronization nightmares Code patterns learned in this chapter Exercises Chapter 9: Working with Parallelized Input/Output and Data Access Queuing threads with I/O operati ons Avoiding Input/Output bott lenecks Using concurrent streams Controlling excepti ons in threads Using a pool of threads with the ThreadPool class Managing the thread queue in the pool Converting single-threaded tasks to a multithreaded pool Encapsulating scalability Thread affinity in a pool of threads Parallelizing database access Code patterns learned in this chapter Exercises Chapter 10: Parallelizing and Concurrently Updating the User Interface Updating the UI from independent threads Creating delegates to make cross-thread calls Reporting progress to the UI from independent threads Creating a delegate without parameters Invoking a delegate asynchronously to avoid performance degradation Code patterns learned in this chapter Exercises Chapter 11: Coding with .NET Parallel Extensions Parallelizing loops using .NET extensions Counting and showing blobs while avoiding side effects Using a parallelized ForEach loop Coding with delegates in parallelized loops Working with a concurrent queue Controlling excepti ons in parallelized loops Combining delegates with a BackgroundWorker Retrieving elements from a concurrent queue in a producer-consumer scheme Creating an asynchronous task combined with a synchronous parallel loop Using lambda expressions to simplify the code Parallelizing loops with ranges Parallelizing queries Parallelizing LINQ queries with PLINQ Specifying the degree of parallelism for PLINQ Parallelizing stati stics and multiple queries Code patterns learned in this chapter Exercises Chapter 12: Developing a Completely Parallelized Application Joining many different parallelized pieces into a complete application Running code out of the UI thread Blocking the UI—Forbidden with multi threading code Combining threads with a pool of threads and the UI thread Creating threads inside other threads Multi ple windows and one UI thread for all of them Rationalizing multi threaded code Code patterns learned in this chapter Exercises
This is a concise practical guide that will help you learn C# threaded programming, with lot of examples and clear explanations. It is packed with screenshots to aid your understanding of the process.
Whether you are a beginner to working with threads or an old hand that is looking for a reference, this book should be on your desk. This book will help you to build scalable, high performance software using parallel programming techniques.
Students learning introductory threaded programming in C# will also gain benefits from this book.
Gastón C. Hillar
Gastón C. Hillar has been working with computers since he was eight. He began programming with the legendary Texas TI-99/4A and Commodore 64 home computers in the early 80’s.
He has a Bachelor degree in Computer Science, graduated with honors and an MBA (Master in Business Administration), graduated with an outstanding thesis. He worked as developer, architect, and project manager for many companies in Buenos Aires, Argentina. Now, he is an independent IT consultant and a freelance author always looking for new adventures around the world. He also works with electronics (he is an electronics technician). He is always researching about new technologies and writing about them. He owns an IT and electronics laboratory with many servers, monitors and measuring instruments.
He is the author of more than 40 books in Spanish about computer science, modern hardware, programming, systems development, software architecture, business applications, balanced scorecard applications, IT project management, Internet and electronics.
He usually writes articles for Spanish magazines “Mundo Linux”, “Solo Programadores” and “Resistor”.
| |
|