Book Image

Visual Studio 2015 Cookbook - Second Edition

By : Jeff Martin
Book Image

Visual Studio 2015 Cookbook - Second Edition

By: Jeff Martin

Overview of this book

Visual Studio 2015 is the premier tool for developers targeting the Microsoft platform. Learning how to effectively use this technology can enhance your productivity while simplifying your most common tasks, allowing you more time to focus on your project. Visual Studio 2015 is packed with improvements that increase productivity, and this book walks you through each one in succession to help you smooth your workflow and get more accomplished. From customization and the interface to code snippets and debugging, the Visual Studio upgrade expands your options — and this book is your fast-track guide to getting on board quickly. Visual Studio 2015 Cookbook will introduce you to all the new areas of Visual Studio and how they can quickly be put to use to improve your everyday development tasks. With this book, you will learn not only what VS2015 offers, but what it takes to put it to work for your projects.
Table of Contents (17 chapters)
Visual Studio 2015 Cookbook Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Debugging parallel code


With the prevalence of multicore CPUs we are seeing more and more applications taking advantage of parallel processing to improve performance. A number of features such as Task Parallel Library (TPL) and Parallel LINQ (PLINQ) were added by .NET Framework 4.0 to make developing applications that take advantage of multicore CPUs much simpler to write.

The debugging experience for threaded applications in Visual Studio has gotten better with each release, and VS2013 is no exception. Let's take a look at what is available.

Getting ready

Start a premium edition of VS2015, and create a new C# console application with a name of your choice.

How to do it…

In order to debug a program with parallel code, perform the following steps:

  1. Use the following code to populate the body of Program.cs. It's a pretty simple program that starts a parallel for loop, which, in turn, calls a method that performs meaningless calculations intended to keep the CPU busy:

    class Program
    {
      static void...