WindowsRuntimeSystemExtensions.AsTask Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AsTask(IAsyncAction) |
Returns a task that represents a Windows Runtime asynchronous action. |
AsTask(IAsyncAction, CancellationToken) |
Returns a task that represents a Windows Runtime asynchronous action that can be cancelled. |
AsTask<TProgress>(IAsyncActionWithProgress<TProgress>) |
Returns a task that represents a Windows Runtime asynchronous action. |
AsTask<TProgress>(IAsyncActionWithProgress<TProgress>, IProgress<TProgress>) |
Returns a task that represents a Windows Runtime asynchronous action that reports progress. |
AsTask<TProgress>(IAsyncActionWithProgress<TProgress>, CancellationToken) |
Returns a task that represents a Windows Runtime asynchronous action that can be cancelled. |
AsTask<TProgress>(IAsyncActionWithProgress<TProgress>, CancellationToken, IProgress<TProgress>) |
Returns a task that represents a Windows Runtime asynchronous action that reports progress and can be cancelled. |
AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, CancellationToken, IProgress<TProgress>) |
Returns a task that represents a Windows Runtime asynchronous operation that returns a result, reports progress, and can be cancelled. |
AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, CancellationToken) |
Returns a task that represents a Windows Runtime asynchronous operation that returns a result and can be cancelled. |
AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>) |
Returns a task that represents a Windows Runtime asynchronous operation returns a result. |
AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, IProgress<TProgress>) |
Returns a task that represents Windows Runtime asynchronous operation that returns a result and reports progress. |
AsTask<TResult>(IAsyncOperation<TResult>) |
Returns a task that represents a Windows Runtime asynchronous operation returns a result. |
AsTask<TResult>(IAsyncOperation<TResult>, CancellationToken) |
Returns a task that represents a Windows Runtime asynchronous operation that returns a result and can be cancelled. |
AsTask(IAsyncAction)
Returns a task that represents a Windows Runtime asynchronous action.
public:
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task ^ AsTask(Windows::Foundation::IAsyncAction ^ source);
public static System.Threading.Tasks.Task AsTask (this Windows.Foundation.IAsyncAction source);
static member AsTask : Windows.Foundation.IAsyncAction -> System.Threading.Tasks.Task
<Extension()>
Public Function AsTask (source As IAsyncAction) As Task
Parameters
- source
- IAsyncAction
The asynchronous action.
Returns
A task that represents the asynchronous action.
Exceptions
source
is null
.
Remarks
Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IAsyncAction. 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).
Use this method to get a Task object for a Windows Runtime asynchronous operation. Task objects simplify the coordination of asynchronous operations.
Applies to
AsTask(IAsyncAction, CancellationToken)
Returns a task that represents a Windows Runtime asynchronous action that can be cancelled.
public:
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task ^ AsTask(Windows::Foundation::IAsyncAction ^ source, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task AsTask (this Windows.Foundation.IAsyncAction source, System.Threading.CancellationToken cancellationToken);
static member AsTask : Windows.Foundation.IAsyncAction * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function AsTask (source As IAsyncAction, cancellationToken As CancellationToken) As Task
Parameters
- source
- IAsyncAction
The asynchronous action.
- cancellationToken
- CancellationToken
A token that can be used to request cancellation of the asynchronous action.
Returns
A task that represents the asynchronous action.
Exceptions
source
is null
.
Remarks
Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IAsyncAction. 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).
Use this method to get a Task object for a Windows Runtime asynchronous operation. Task objects simplify the coordination of asynchronous operations.
Applies to
AsTask<TProgress>(IAsyncActionWithProgress<TProgress>)
Returns a task that represents a Windows Runtime asynchronous action.
public:
generic <typename TProgress>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task ^ AsTask(Windows::Foundation::IAsyncActionWithProgress<TProgress> ^ source);
public static System.Threading.Tasks.Task AsTask<TProgress> (this Windows.Foundation.IAsyncActionWithProgress<TProgress> source);
static member AsTask : Windows.Foundation.IAsyncActionWithProgress<'Progress> -> System.Threading.Tasks.Task
<Extension()>
Public Function AsTask(Of TProgress) (source As IAsyncActionWithProgress(Of TProgress)) As Task
Type Parameters
- TProgress
The type of object that provides data that indicates progress.
Parameters
- source
- IAsyncActionWithProgress<TProgress>
The asynchronous action.
Returns
A task that represents the asynchronous action.
Exceptions
source
is null
.
Remarks
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).
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<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, IProgress<TProgress>) extension method overload and specifying null
for the progress
parameter. This is useful when you don't want to get progress reports from an action that reports progress.
Applies to
AsTask<TProgress>(IAsyncActionWithProgress<TProgress>, IProgress<TProgress>)
Returns a task that represents a Windows Runtime asynchronous action that reports progress.
public:
generic <typename TProgress>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task ^ AsTask(Windows::Foundation::IAsyncActionWithProgress<TProgress> ^ source, IProgress<TProgress> ^ progress);
public static System.Threading.Tasks.Task AsTask<TProgress> (this Windows.Foundation.IAsyncActionWithProgress<TProgress> source, IProgress<TProgress> progress);
static member AsTask : Windows.Foundation.IAsyncActionWithProgress<'Progress> * IProgress<'Progress> -> System.Threading.Tasks.Task
<Extension()>
Public Function AsTask(Of TProgress) (source As IAsyncActionWithProgress(Of TProgress), progress As IProgress(Of TProgress)) As Task
Type Parameters
- TProgress
The type of object that provides data that indicates progress.
Parameters
- source
- IAsyncActionWithProgress<TProgress>
The asynchronous action.
- progress
- IProgress<TProgress>
An object that receives progress updates.
Returns
A task that represents the asynchronous action.
Exceptions
source
is null
.
Remarks
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).
Use this method to get a Task object for a Windows Runtime asynchronous operation. Task objects simplify the coordination of asynchronous operations.
Applies to
AsTask<TProgress>(IAsyncActionWithProgress<TProgress>, CancellationToken)
Returns a task that represents a Windows Runtime asynchronous action that can be cancelled.
public:
generic <typename TProgress>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task ^ AsTask(Windows::Foundation::IAsyncActionWithProgress<TProgress> ^ source, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task AsTask<TProgress> (this Windows.Foundation.IAsyncActionWithProgress<TProgress> source, System.Threading.CancellationToken cancellationToken);
static member AsTask : Windows.Foundation.IAsyncActionWithProgress<'Progress> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function AsTask(Of TProgress) (source As IAsyncActionWithProgress(Of TProgress), cancellationToken As CancellationToken) As Task
Type Parameters
- TProgress
The type of object that provides data that indicates progress.
Parameters
- source
- IAsyncActionWithProgress<TProgress>
The asynchronous action.
- cancellationToken
- CancellationToken
A token that can be used to request cancellation of the asynchronous action.
Returns
A task that represents the asynchronous action.
Exceptions
source
is null
.
Remarks
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).
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<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, CancellationToken, IProgress<TProgress>) extension method overload and specifying null
for the progress
parameter. This is useful when you don't want to get progress reports from an action that reports progress.
Applies to
AsTask<TProgress>(IAsyncActionWithProgress<TProgress>, CancellationToken, IProgress<TProgress>)
Returns a task that represents a Windows Runtime asynchronous action that reports progress and can be cancelled.
public:
generic <typename TProgress>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task ^ AsTask(Windows::Foundation::IAsyncActionWithProgress<TProgress> ^ source, System::Threading::CancellationToken cancellationToken, IProgress<TProgress> ^ progress);
public static System.Threading.Tasks.Task AsTask<TProgress> (this Windows.Foundation.IAsyncActionWithProgress<TProgress> source, System.Threading.CancellationToken cancellationToken, IProgress<TProgress> progress);
static member AsTask : Windows.Foundation.IAsyncActionWithProgress<'Progress> * System.Threading.CancellationToken * IProgress<'Progress> -> System.Threading.Tasks.Task
<Extension()>
Public Function AsTask(Of TProgress) (source As IAsyncActionWithProgress(Of TProgress), cancellationToken As CancellationToken, progress As IProgress(Of TProgress)) As Task
Type Parameters
- TProgress
The type of object that provides data that indicates progress.
Parameters
- source
- IAsyncActionWithProgress<TProgress>
The asynchronous action.
- cancellationToken
- CancellationToken
A token that can be used to request cancellation of the asynchronous action.
- progress
- IProgress<TProgress>
An object that receives progress updates.
Returns
A task that represents the asynchronous action.
Exceptions
source
is null
.
Remarks
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).
Use this method to get a Task object for a Windows Runtime asynchronous operation. Task objects simplify the coordination of asynchronous operations.
Applies to
AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, CancellationToken, IProgress<TProgress>)
Returns a task that represents a Windows Runtime asynchronous operation that returns a result, reports progress, and can be cancelled.
public:
generic <typename TResult, typename TProgress>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<TResult> ^ AsTask(Windows::Foundation::IAsyncOperationWithProgress<TResult, TProgress> ^ source, System::Threading::CancellationToken cancellationToken, IProgress<TProgress> ^ progress);
public static System.Threading.Tasks.Task<TResult> AsTask<TResult,TProgress> (this Windows.Foundation.IAsyncOperationWithProgress<TResult,TProgress> source, System.Threading.CancellationToken cancellationToken, IProgress<TProgress> progress);
static member AsTask : Windows.Foundation.IAsyncOperationWithProgress<'Result, 'Progress> * System.Threading.CancellationToken * IProgress<'Progress> -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function AsTask(Of TResult, TProgress) (source As IAsyncOperationWithProgress(Of TResult, TProgress), cancellationToken As CancellationToken, progress As IProgress(Of TProgress)) As Task(Of TResult)
Type Parameters
- TResult
The type of object that returns the result of the asynchronous operation.
- TProgress
The type of object that provides data that indicates progress.
Parameters
- source
- IAsyncOperationWithProgress<TResult,TProgress>
The asynchronous operation.
- cancellationToken
- CancellationToken
A token that can be used to request cancellation of the asynchronous operation.
- progress
- IProgress<TProgress>
An object that receives progress updates.
Returns
A task that represents the asynchronous operation.
Remarks
Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IAsyncOperationWithProgress<TResult,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).
Use this method to get a Task<TResult> object for a Windows Runtime asynchronous operation. Task<TResult> objects simplify the coordination of asynchronous operations.
Applies to
AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, CancellationToken)
Returns a task that represents a Windows Runtime asynchronous operation that returns a result and can be cancelled.
public:
generic <typename TResult, typename TProgress>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<TResult> ^ AsTask(Windows::Foundation::IAsyncOperationWithProgress<TResult, TProgress> ^ source, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<TResult> AsTask<TResult,TProgress> (this Windows.Foundation.IAsyncOperationWithProgress<TResult,TProgress> source, System.Threading.CancellationToken cancellationToken);
static member AsTask : Windows.Foundation.IAsyncOperationWithProgress<'Result, 'Progress> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function AsTask(Of TResult, TProgress) (source As IAsyncOperationWithProgress(Of TResult, TProgress), cancellationToken As CancellationToken) As Task(Of TResult)
Type Parameters
- TResult
The type of object that returns the result of the asynchronous operation.
- TProgress
The type of object that provides data that indicates progress.
Parameters
- source
- IAsyncOperationWithProgress<TResult,TProgress>
The asynchronous operation.
- cancellationToken
- CancellationToken
A token that can be used to request cancellation of the asynchronous operation.
Returns
A task that represents the asynchronous operation.
Exceptions
source
is null
.
Remarks
Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IAsyncOperationWithProgress<TResult,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).
Use this method to get a Task<TResult> object for a Windows Runtime asynchronous operation. Task<TResult> objects simplify the coordination of asynchronous operations.
Calling this method overload is equivalent to calling the AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, CancellationToken, IProgress<TProgress>) extension method overload and specifying null
for the progress
parameter. This is useful when you don't want to get progress reports from an action that reports progress.
Applies to
AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>)
Returns a task that represents a Windows Runtime asynchronous operation returns a result.
public:
generic <typename TResult, typename TProgress>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<TResult> ^ AsTask(Windows::Foundation::IAsyncOperationWithProgress<TResult, TProgress> ^ source);
public static System.Threading.Tasks.Task<TResult> AsTask<TResult,TProgress> (this Windows.Foundation.IAsyncOperationWithProgress<TResult,TProgress> source);
static member AsTask : Windows.Foundation.IAsyncOperationWithProgress<'Result, 'Progress> -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function AsTask(Of TResult, TProgress) (source As IAsyncOperationWithProgress(Of TResult, TProgress)) As Task(Of TResult)
Type Parameters
- TResult
The type of object that returns the result of the asynchronous operation.
- TProgress
The type of object that provides data that indicates progress.
Parameters
- source
- IAsyncOperationWithProgress<TResult,TProgress>
The asynchronous operation.
Returns
A task that represents the asynchronous operation.
Exceptions
source
is null
.
Remarks
Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IAsyncOperationWithProgress<TResult,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).
Use this method to get a Task<TResult> object for a Windows Runtime asynchronous operation. Task<TResult> objects simplify the coordination of asynchronous operations.
Calling this method overload is equivalent to calling the AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, IProgress<TProgress>) extension method overload and specifying null
for the progress
parameter. This is useful when you don't want to get progress reports from an action that reports progress.
Applies to
AsTask<TResult,TProgress>(IAsyncOperationWithProgress<TResult,TProgress>, IProgress<TProgress>)
Returns a task that represents Windows Runtime asynchronous operation that returns a result and reports progress.
public:
generic <typename TResult, typename TProgress>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<TResult> ^ AsTask(Windows::Foundation::IAsyncOperationWithProgress<TResult, TProgress> ^ source, IProgress<TProgress> ^ progress);
public static System.Threading.Tasks.Task<TResult> AsTask<TResult,TProgress> (this Windows.Foundation.IAsyncOperationWithProgress<TResult,TProgress> source, IProgress<TProgress> progress);
static member AsTask : Windows.Foundation.IAsyncOperationWithProgress<'Result, 'Progress> * IProgress<'Progress> -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function AsTask(Of TResult, TProgress) (source As IAsyncOperationWithProgress(Of TResult, TProgress), progress As IProgress(Of TProgress)) As Task(Of TResult)
Type Parameters
- TResult
The type of object that returns the result of the asynchronous operation.
- TProgress
The type of object that provides data that indicates progress.
Parameters
- source
- IAsyncOperationWithProgress<TResult,TProgress>
The asynchronous operation.
- progress
- IProgress<TProgress>
An object that receives progress updates.
Returns
A task that represents the asynchronous operation.
Exceptions
source
is null
.
Remarks
Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IAsyncOperationWithProgress<TResult,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).
Use this method to get a Task<TResult> object for a Windows Runtime asynchronous operation. Task<TResult> objects simplify the coordination of asynchronous operations.
Applies to
AsTask<TResult>(IAsyncOperation<TResult>)
Returns a task that represents a Windows Runtime asynchronous operation returns a result.
public:
generic <typename TResult>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<TResult> ^ AsTask(Windows::Foundation::IAsyncOperation<TResult> ^ source);
public static System.Threading.Tasks.Task<TResult> AsTask<TResult> (this Windows.Foundation.IAsyncOperation<TResult> source);
static member AsTask : Windows.Foundation.IAsyncOperation<'Result> -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function AsTask(Of TResult) (source As IAsyncOperation(Of TResult)) As Task(Of TResult)
Type Parameters
- TResult
The type of object that returns the result of the asynchronous operation.
Parameters
- source
- IAsyncOperation<TResult>
The asynchronous operation.
Returns
A task that represents the asynchronous operation.
Exceptions
source
is null
.
Remarks
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).
Use this method to get a Task<TResult> object for a Windows Runtime asynchronous operation. Task<TResult> objects simplify the coordination of asynchronous operations.
Applies to
AsTask<TResult>(IAsyncOperation<TResult>, CancellationToken)
Returns a task that represents a Windows Runtime asynchronous operation that returns a result and can be cancelled.
public:
generic <typename TResult>
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<TResult> ^ AsTask(Windows::Foundation::IAsyncOperation<TResult> ^ source, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<TResult> AsTask<TResult> (this Windows.Foundation.IAsyncOperation<TResult> source, System.Threading.CancellationToken cancellationToken);
static member AsTask : Windows.Foundation.IAsyncOperation<'Result> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function AsTask(Of TResult) (source As IAsyncOperation(Of TResult), cancellationToken As CancellationToken) As Task(Of TResult)
Type Parameters
- TResult
The type of object that returns the result of the asynchronous operation.
Parameters
- source
- IAsyncOperation<TResult>
The asynchronous operation.
- cancellationToken
- CancellationToken
A token that can be used to request cancellation of the asynchronous operation.
Returns
A task that represents the asynchronous operation.
Exceptions
source
is null
.
Remarks
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).
Use this method to get a Task<TResult> object for a Windows Runtime asynchronous operation. Task<TResult> objects simplify the coordination of asynchronous operations.