WindowsRuntimeSystemExtensions.AsAsyncOperation<TResult> Method

.NET Framework 4.5

Returns a Windows Runtime asynchronous operation that represents a started task that returns a result.

Namespace:  System
Assembly:  System.Runtime.WindowsRuntime (in System.Runtime.WindowsRuntime.dll)

public static IAsyncOperation<TResult> AsAsyncOperation<TResult>(
	this Task<TResult> source
)

Type Parameters

TResult

The type that returns the result.

Parameters

source
Type: System.Threading.Tasks.Task<TResult>

The started task.

Return Value

Type: IAsyncOperation<TResult>
A Windows.Foundation.IAsyncOperation<TResult> instance that represents the started task.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Task<TResult>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

ExceptionCondition
ArgumentNullException

source is null.

InvalidOperationException

source is an unstarted task.

Use this method when you want to pass a task that returns a result to a Windows Runtime method that takes an asynchronous operation.

The AsyncInfo class provides static methods (Shared methods in Visual Basic) that create and start Windows Runtime asynchronous operations that represent tasks that return results and can respond to cancellation requests and report progress.

.NET Framework

Supported in: 4.5

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Silverlight 8.1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft