Look At Tasks Window In VS 2015

It is available during debugging only and helpful to examine the tasks which are running asynchronous operations concurrently within a thread. We can have multiple tasks running on the same thread. We can open Tasks Window in VS 2015 from Debug -> Windows -> Tasks or using shortcut Ctrl+Shift+D, K.


We can use Tasks Window in the following

  • Managed code- It is used to work with System.Threading.Tasks.Task objects or with the await and async keywords.
  • Native code- It is used to work with the task groups, parallel algorithms, asynchronous agents and lightweight tasks.
  • JavaScript- To work with promise, followed by the code.

Let’s create a console application to understand it better with the code give below.


Here, we created two tasks and executed the same method to display the task ID and sleep the current task for 1 second. Let’s keep a breakpoint and debug it to examine those tasks in Tasks Window.


Let’s look at the columns, which are helpful in Tasks Window given below.

  • Flag column is used to flag\unflag a task on which we need to focus on.
  • Icon column indicates currently executing task with a Yellow indicator, White arrow for breaking task and pause icon for the task frozen by the user.
  • The ID column contains a system generated identification number of the task.
  • Status column displays the current state of the task. It will show one of the states given below.
  • Scheduled,
  • Active
  • Deadlocked,
  • Waiting or
  • Completed

A scheduled task that has not yet been run will not have a call stack, assigned thread or the related information.

  • Location column helps to look at the currently executing code.

We can add\remove the columns, as shown below.


We can group and sort the tasks as well.


We can freeze a thread on which the task is running, so that it will not execute when you step through the code after the current breakpoint


The “Freeze All Threads But This One” command freezes all the threads except the one that is selected in the task list.

Similarly, we can resume\un-freeze a thread, which runs the task by clicking on Thaw Assigned Thread.


I am ending  things here. I hope this is informative.

Up Next
    Ebook Download
    View all
    Learn
    View all