WindowsRuntimeSystemExtensions::AsTask<TProgress> Method (IAsyncActionWithProgress<TProgress>)
Returns a task that represents a Windows Runtime asynchronous action.
Namespace: System
Assembly: System.Runtime.WindowsRuntime (in System.Runtime.WindowsRuntime.dll)
[ExtensionAttribute] public: generic<typename TProgress> static Task^ AsTask( IAsyncActionWithProgress<TProgress>^ source )
Type Parameters
- TProgress
The type of object that provides data that indicates progress.
Parameters
- source
- Type: IAsyncActionWithProgress<TProgress>
The asynchronous action.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IAsyncActionWithProgress<TProgress>. 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).| Exception | Condition |
|---|---|
| ArgumentNullException | source is nullptr. |
Use this method to get a Task object for a Windows Runtime asynchronous operation. Task objects simplify the coordination of asynchronous operations.
Calling this method overload is equivalent to calling the AsTask<TProgress>(IAsyncActionWithProgress<TProgress>, IProgress<TProgress>) extension method overload and specifying nullptr for the progress parameter. This is useful when you don't want to get progress reports from an action that reports progress.