System.Threading.Tasks.TaskExtensions.Unwrap Method

Creates a proxy System.Threading.Tasks.Task that represents the asynchronous operation of a TaskScheduler.TryExecuteTaskInline(Task, bool).

Syntax

public static Task Unwrap (this Task<Task> task)

Parameters

task
The Task<Task> (C#) or Task (Of Task) (Visual Basic) to unwrap.

Returns

A Task that represents the asynchronous operation of the provided System.Threading.Tasks.Task(Of Task).

Remarks

It is often useful to be able to return a Task from a System.Threading.Tasks.Task`1, where the inner Task represents work done as part of the outer System.Threading.Tasks.Task`1. However, doing so results in a Task<Task> (C#) or Task (Of Task) (Visual Basic), which, if not dealt with carefully, could produce unexpected behavior. Unwrap solves this problem by creating a proxy Task that represents the entire asynchronous operation of such a task.

Requirements

Namespace: System.Threading.Tasks
Assembly: System.Core (in System.Core.dll)
Assembly Versions: 4.0.0.0