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

Back to BOOK PAGE

Table of Contents

Preface
Chapter 1: Taking Advantage of Multiprocessing and Multiple Cores
Chapter 2: Processes and Threads
Chapter 3: BackgroundWorker—Putting Threads to Work
Chapter 4: Thread Class—Practical Multithreading in Applications
Chapter 5: Simple Debugging Techniques with Multithreading
Chapter 6: Understanding Thread Control with Patterns
Chapter 7: Dynamically Splitting Jobs into Pieces—Avoiding Problems
Chapter 8: Simplifying Parallelism Complexity
Chapter 9: Working with Parallelized Input/Output and Data Access
Chapter 10: Parallelizing and Concurrently Updating the User Interface
Chapter 11: Coding with .NET Parallel Extensions
Chapter 12: Developing a Completely Parallelized Application
Index

  • Chapter 1: Taking Advantage of Multiprocessing and Multiple Cores
    • Mono-processor systems: The old gladiators
      • Single core: Only one warrior to fight against everybody
      • Doing a tiny bit of each task
    • 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
    • Summary
  • Chapter 2: Processes and Threads
    • Processes—any running program
      • Time for action – Coding a simple CPU-intensive loop
      • Time for action – Changing the cores available for a process
    • Relating processes to cores
      • Time for action – Changing a process priority
    • Linear code problems in multiprocessing systems
      • Time for action – Running many processes in parallel
      • Time for action – Testing parallelism capabilities with processes
      • Time for action – Using the Process Explorer
  • Threads—Independent parts of a process
    • Time for action – Listing threads with Process Explorer
    • Time for action – Analyzing context switches with Process Explorer
  • Multiple threads in servers
  • Multiple threads in clients
  • Summary
  • Asynchronous execution
    • Time for action - Understanding asynchronous execution step-by-step
  • Synchronous execution
  • Showing the progress
    • Time for action – Using a BackgroundWorker to report progress in the UI
  • Cancelling the job
    • Time for action – Using a BackgroundWorker to cancel the job
    • Time for action – Using a BackgroundWorker to detect a job completed
    • Time for action – Working with parameters and results
  • Working with multiple BackgroundWorker components
    • Time for action – Using many BackgroundWorker components to break
    • the code faster
  • BackgroundWorker and Timer
  • BackgroundWorker creation on the fly
    • Time for action – Creating BackgroundWorker components in run-time
  • Summary
  • Sharing data between threads
    • Time for action – Updating the UI while running threads
  • Sharing some specific data between threads
  • A BackgroundWorker helping a Thread class
    • Time for action – Executing the thread synchronously
  • Main and secondary threads
  • Passing parameters to threads
    • Time for action – Using lists for thread creation on the fly I
    • Time for action – Using lists for thread creation on the fly II
  • Creating as many threads as the number of cores
  • Receiving parameters in the thread method
  • Summary
  • Chapter 5: Simple Debugging Techniques with Multithreading
    • Watching multiple threads
      • Time for action – Understanding the difficulty in debugging
      • concurrent threads
    • Debugging concurrent threads
      • Time for action – Finding the threads
    • Understanding the information shown in the Threads window
      • Time for action – Assigning names to threads
    • Identifying the current thread at runtime
  • Debugging multithreaded applications as single-threaded applications
    • Time for action – Leaving a thread running alone
  • Freezing and thawing threads
  • Viewing the call stack for each running thread
  • Showing partial results in multithreaded code
    • Time for action – Explaining the encryption procedure
  • Showing thread-safe output
    • Time for action – Isolating results
  • Understanding thread information in tracepoints
  • Summary
  • Understanding the pixels' color compositions
    • Time for action – Running the stars counter in many concurrent threads
  • Creating independent blocks of concurrent code
    • Using flags to enhance control over concurrent threads
    • Rebuilding results to show in the UI
    • Testing results with Performance Monitor and Process Explorer
      • Time for action –Waiting for the threads' signals
    • Using the AutoResetEvent class to handle signals between threads
    • Using the WaitHandle class to check for signals
  • Summary
  • Chapter 7: Dynamically Splitting Jobs into Pieces—Avoiding Problems
    • Running split jobs many times
      • Time for action – Defining new methods for running many times
      • Time for action – Running a multithreaded algorithm many times
    • Using classes, methods, procedures, and functions with multithreading capabilities
      • Time for action – Analyzing the memory usage
    • Understanding the garbage collector with multithreading
      • Time for action – Collecting the garbage at the right time
    • 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
    • Time for action – Creating a parallel algorithm piece class
    • Time for action – Using a generic method in order to create pieces
  • Creating the pieces
    • Time for action – Creating a parallel algorithm coordination class
  • Starting the threads associated to the pieces
  • Accessing instances and variables from threads' methods
    • Time for action – Adding useful classic coordination methods
  • Summary
  • Chapter 8: Simplifying Parallelism Complexity
    • Specializing the algorithms for segmentation with classes
      • Time for action – Preparing the parallel algorithm classes for the
      • factory method
    • Defining the class to instantiate
    • Preparing the classes for inheritance
      • Time for action – Creating a specialized parallel algorithm piece subclass
    • Creating a complete piece of work
    • Writing the code for a thread in an instance method
      • Time for action – Creating a specialized parallel algorithm
      • coordination subclass
    • Creating simple constructors
      • Time for action—Overriding methods in the coordination subclass
      • Programming the piece creation method
    • Programming the results collection method
      • Time for action – Defining a new method to create an algorithm instance
    • Forgetting about threads
      • Time for action – Running the Sunspot Analyzer in many concurrent
      • independent pieces
    • Optimizing and encapsulating parallel algorithms
    • Achieving thread affinity
  • Avoiding locks and many synchronization nightmares
  • Summary
  • Chapter 9: Working with Parallelized Input/Output and Data Access
    • Queuing threads with I/O operations
      • Time for action – Creating a class to run an algorithm in an
      • independent thread
      • Time for action – Putting the logic into methods to simplify multithreading
    • Avoiding Input/Output bottlenecks
    • Using concurrent streams
    • Controlling exceptions in threads
      • Time for action – Creating the methods for queuing requests
    • Using a pool of threads with the ThreadPool class
    • Managing the thread queue in the pool
      • Time for action – Running concurrent encryptions on demand using a
      • pool of threads
    • Converting single-threaded tasks to a multithreaded pool
    • Encapsulating scalability
    • Thread affinity in a pool of threads
  • Parallelizing database access
  • Summary
  • Chapter 10: Parallelizing and Concurrently Updating the User Interface
    • Updating the UI from independent threads
      • Time for action – Creating a safe method to update the user interface
    • Creating delegates to make cross-thread calls
    • Figuring out the right thread to make the call to the UI
    • Avoiding UI update problems with a delegate
    • Retrieving results from a synchronous delegate invoke
      • Time for action – Invoking a user interface update from a thread
    • Providing feedback when the work is finished
      • Time for action – Identifying threads and giving them names
      • Time for action – Understanding how to invoke delegates step-by-step
    • Decoding the delegates and concurrency puzzle
      • Time for action – Creating safe counters using delegates and avoiding
      • concurrency problems
    • Taking advantage of the single-threaded UI to create safe counters
  • Reporting progress to the UI from independent threads
    • Time for action – Creating the classes to show a progress bar column in a
    • DataGridView
    • Time for action – Creating a class to hold the information to show in the
    • DataGridView
    • Time for action – Invoking multiple asynchronous user interface updates
    • from many threads
  • Creating a delegate without parameters
  • Invoking a delegate asynchronously to avoid performance degradation
    • Time for action – Updating progress percentages from worker threads
  • Providing feedback while the work is being done
  • Summary
  • Chapter 11: Coding with .NET Parallel Extensions
    • Parallelizing loops using .NET extensions
      • Time for action – Downloading and installing the .NET Parallel Extensions
    • No silver bullet
      • Time for action – Downloading and installing the imaging library
      • Time for action – Creating an independent class to run in parallel without
      • side effects
    • Counting and showing blobs while avoiding side effects
      • Time for action – Running concurrent nebula finders using a
      • parallelized loop
    • Using a parallelized ForEach loop
    • Coding with delegates in parallelized loops
    • Working with a concurrent queue
    • Controlling exceptions in parallelized loops
      • Time for action – Showing the results in the UI
    • Combining delegates with a BackgroundWorker
    • Retrieving elements from a concurrent queue in a producer-consumer scheme
      • Time for action – Providing feedback to the UI using a producer-consumer
      • scheme
    • Creating an asynchronous task combined with a synchronous parallel loop
      • Time for action – Invoking a UI update from a task
    • Providing feedback when each job is finished
    • Using lambda expressions to simplify the code
    • Parallelizing loops with ranges
  • Parallelizing queries
    • Time for action – Parallelized counter
  • Parallelizing LINQ queries with PLINQ
  • Specifying the degree of parallelism for PLINQ
  • Parallelizing statistics and multiple queries
  • Summary
  • Chapter 12: Developing a Completely Parallelized Application
    • Joining many different parallelized pieces into a complete application
      • Time for action – Creating an opacity effect in an independent thread
    • Running code out of the UI thread
      • Time for action – Creating a safe method to change the opacity
    • Blocking the UI—Forbidden with multithreading code
      • Time for action – Creating a class to run a task in an independent thread
      • Time for action – Putting the logic into methods to simplify running tasks
      • in a pool of threads
      • Time for action – Queuing requests, running threads, and updating the UI
    • Combining threads with a pool of threads and the UI thread
      • Time for action – Creating a specialized parallel algorithm piece subclass
      • to run concurrently with the pool of threads
      • Time for action – Creating a specialized parallel algorithm coordination
      • subclass to run concurrently with the pool of threads
      • Time for action – Overriding methods in the brightness adjustment
      • coordination subclass
      • Time for action – Starting new threads in a new window
    • Creating threads inside other threads
      • Time for action – Showing new windows without blocking the user
      • interface
    • Multiple windows and one UI thread for all of them
  • Rationalizing multithreaded code
  • Summary

Back to BOOK PAGE

Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Sort A-Z