Export (0) Print
Expand All

Using the Parallel Tasks Window

The Parallel Tasks window resembles the Threads window, except that it shows information about each 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 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.

Parallel Tasks Window
Note Note

In managed code, a Task that has a status of Created, WaitingForActivation, or WaitingToRun might not be displayed in the Parallel Tasks window when managed threads are in a sleep or join state.

The columns in the Parallel Tasks window show the following information.

Column Name

Description

Flags

Shows which tasks are flagged and lets you flag or unflag a task.

Icons

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.

ID

A system-provided number for the task. In native code, this is the address of the task.

Status

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.

Caution note Caution

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.

Location

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.

Task

The initial method and any arguments that were passed to the task when it was created.

Parent

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.

Thread Assignment

The ID and name of the thread on which the task is running.

AppDomain

For managed code, the application domain in which the task is executing.

task_group

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.

Process

The ID of the process that the task is running on.

Async State

For managed code, the task status. By default, this column is hidden. To display this column, open the context menu for one of the column headers. Choose Columns, AsyncState.

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.

Parallel Tasks Context Menu

To sort tasks by column criteria, click the column header. For example, by clicking the ID column header, you can sort the tasks by task ID: 1,2,3,4,5 and so on. To reverse the sort order, click the column header again. The current sort column and sort order is indicated by an arrow on the column.

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.

Parallel Tasks 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.

Parallel Tasks Parent-Child View

You can flag the thread the task on which a task is running 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.

Parallel Tasks context menu
Show:
© 2014 Microsoft