Using the Parallel Tasks Window
Updated: March 2011
The Parallel Tasks window resembles the Threads window, except that it shows information about each System.Threading.Tasks.Task or task_handle object instead of each thread. Like threads, tasks represent asynchronous operations that can run concurrently; however, multiple tasks may run on the same thread.
In managed code, you can use the Parallel Tasks window when you work with System.Threading.Tasks.Task objects. For more information about tasks in managed code, see Parallel Programming in the .NET Framework.
In native code, you can use the Parallel Tasks window when you work with task groups, parallel algorithms, asynchronous agents, and lightweight tasks. For more information about tasks in native code, see Concurrency Runtime.
You can use the Parallel Tasks window whenever you break into the debugger. You can access it on the Debug menu by clicking Windows and then clicking Parallel Tasks. The following illustration shows the Parallel Tasks window in its default mode.
The columns in the Parallel Tasks window show the following information.
Shows which tasks are flagged and lets you flag or unflag a task.
A yellow arrow indicates the current task. The current task is the top-most task on the current thread.
A white arrow indicates the breaking task, that is, the one that was current when the debugger was invoked.
The pause icon indicates a task that has been frozen by the user. You can freeze and unfreeze a task by right-clicking it in the list.
A system-provided number for the task. In native code, this is the address of the task.
The current state (scheduled, running, deadlocked, or waiting) of the task. A scheduled task is one that has not yet been run and, therefore, does not yet have a call stack, assigned thread, or related information.
A running task is one that was executing code before breaking in the debugger.
A waiting task is one that is blocked because it is waiting on an event to be signaled, a lock to be released, or another task to finish.
A deadlocked task is a waiting task whose thread is deadlocked with another thread.
Hover over the Status cell for a deadlocked or waiting task to see more information about the block.
The Parallel Tasks window reports deadlock only for a blocked task that uses a synchronization primitive that is supported by Wait Chain Traversal (WCT). For example, for a deadlocked Task object, which uses WCT, the debugger reports Waiting-deadlocked. For a deadlocked task that is managed by the Concurrency Runtime, which does not use WCT, the debugger reports Waiting. For more information about WCT, see Wait Chain Traversal.
The current location in the call stack of the task. Hover over this cell to see the entire call stack for the task. Scheduled tasks do not have a value in this column.
The initial method and any arguments that were passed to the task when it was created.
The ID of the task that created this task. If this is blank, the task has no parent. This is only applicable for managed programs.
The ID and name of the thread on which the task is running.
For managed code, the application domain in which the task is executing.
For native code, the address of the task_group object that scheduled the task. For asynchronous agents and lightweight tasks, this column is set to 0.
You can add columns to the view by right-clicking a column heading and then selecting the columns you want. (Remove columns by clearing the selections.) You can also reorder columns by dragging them left or right. The column shortcut menu is shown in the following illustration.
You can group tasks based on any column in the list view. For example, by right-clicking the Status column header and then clicking Group by Status, you can group all tasks that have the same status. For example, you could quickly see waiting tasks so that you could focus on why they are blocked. You can also collapse a group that is not of interest during the debug session. In the same manner, you can group by the other columns. A group can be (un)flagged just by clicking the button next to the group header. The following illustration shows the Parallel Tasks window in grouped mode.
(This view is available for managed code only.) By right-clicking a column heading and then clicking Parent Child View, you can change the list of tasks to a hierarchical view, in which every child task is a sub-node that can be displayed or hidden under its parent. The following illustration shows the tasks in parent-child view.
You can flag a task by right-clicking the task list item and then clicking Flag, or by clicking the flag icon in the first column. If you flag several tasks, you can then sort on the flag column to bring all the flagged tasks to the top so that you can focus just on them. You can also use the Parallel Stacks window to view only flagged tasks. This lets you filter out tasks that you are not interested in for debugging. Flags are not persisted between debugging sessions.
You can freeze the thread on which a task is running by right-clicking the task list item and then clicking Freeze Assigned Thread. (If a task is already frozen, the command is Thaw Assigned Thread.) When you freeze a thread, that thread will not execute when you step through code after the current breakpoint. The Freeze All Threads But This command freezes all threads except the one that is executing the task list item.
The following illustration shows the other menu items for each task.