WindowsRuntimeSystemExtensions.AsTask(Of TResult, TProgress) Method (IAsyncOperationWithProgress(Of TResult, TProgress), CancellationToken)
Returns a task that represents a Windows Runtime asynchronous operation that returns a result and can be cancelled.
Assembly: System.Runtime.WindowsRuntime (in System.Runtime.WindowsRuntime.dll)
'Declaration <ExtensionAttribute> _ Public Shared Function AsTask(Of TResult, TProgress) ( _ source As IAsyncOperationWithProgress(Of TResult, TProgress), _ cancellationToken As CancellationToken _ ) As Task(Of TResult)
The type of object that returns the result of the asynchronous operation.
The type of object that provides data that indicates progress.
- Type: IAsyncOperationWithProgress(Of , )
The asynchronous operation.
- Type: System.Threading.CancellationToken
A token that can be used to request cancellation of the asynchronous operation.
Return ValueType: System.Threading.Tasks.Task(Of )
A task that represents the asynchronous operation.
Usage NoteIn Visual Basic and C#, you can call this method as an instance method on any object of type IAsyncOperationWithProgress(Of , ). 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).
Calling this method overload is equivalent to calling the AsTask(Of TResult, TProgress)(IAsyncOperationWithProgress(Of TResult, TProgress), CancellationToken, IProgress(Of TProgress)) extension method overload and specifying Nothing for the progress parameter. This is useful when you don't want to get progress reports from an operation that reports progress.
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.