Parallel programming can improve the performance and responsiveness of applications, but sometimes the results are not as expected. Common problems related to parallel/asynchronous code are performance and correctness.
With performance, we mean that the results of execution are slow. With correctness, we mean that results are not as expected (this might be due to race conditions). Another big issue when dealing with multiple concurrent tasks is deadlocks. Debugging multithreaded code is always a challenge as threads keep switching while you are debugging. While working on GUI-based applications, it's also important to find out which thread is running our code.
In this chapter, we will explain how to debug threads using tools available in Visual Studio, including the Threads window, the Tasks window, and Concurrency Visualizer.
In this chapter...