IAsyncOperationWithProgress Interface
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.
Represents an asynchronous operation that can report progress updates to callers. This is the return type for many Windows Runtime asynchronous methods that have results and also report progress.
public interface class IAsyncOperationWithProgress : IAsyncInfo
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(3050321623, 58007, 18831, 186, 96, 2, 137, 231, 110, 35, 221)]
template
struct IAsyncOperationWithProgress : IAsyncInfo
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
[Windows.Foundation.Metadata.Guid(3050321623, 58007, 18831, 186, 96, 2, 137, 231, 110, 35, 221)]
public interface IAsyncOperationWithProgress : IAsyncInfo
Public Interface IAsyncOperationWithProgress(Of TResult, TProgress)
Implements IAsyncInfo
Type Parameters
- TResult
- TProgress
- Derived
- Attributes
- Implements
Windows requirements
| Requirements | Description |
|---|---|
| Device family |
Windows 10 (introduced in 10.0.10240.0)
|
| API contract |
Windows.Foundation.FoundationContract (introduced in v1.0)
|
Remarks
IAsyncOperationWithProgress
When you use methods that return IAsyncOperationWithProgress
It's not common to use IAsyncOperationWithProgress
Specifically, if you want to handle progress in .NET code, use the AsTask signature that in an extension usage has a single IProgress reference parameter. (In this usage, the progress unit is already constrained and matches the IAsyncOperationWithProgress method you're using.) Provide an object that implements IProgress, and your Report method implementation is invoked each time the Windows Runtime method reports a progress notification.
To monitor the progress of the action (if not using the language-specific techniques described above), set the Progress property, providing it the name of a method that implements the AsyncOperationProgressHandler
C++/WinRT extension functions
Note
Extension functions exist on the C++/WinRT projection types for certain Windows Runtime APIs. For example, winrt::Windows::Foundation::IAsyncAction is the C++/WinRT projection type for IAsyncAction. The extension functions aren't part of the application binary interface (ABI) surface of the actual Windows Runtime types, so they're not listed as members of the Windows Runtime APIs. But you can call them from within any C++/WinRT project. See C++/WinRT functions that extend Windows Runtime APIs.
TResult get() const;
Waits synchronously for the operation to complete, and returns the completed value. Throws a corresponding exception if the operation is canceled, or enters an error state. You mustn't call it from a single-threaded apartment. For more info, and code examples showing how to call get, see Write a coroutine.
AsyncStatus wait_for(TimeSpan const& timeout) const;
Waits synchronously for the operation to complete, or for the specified timeout. Returns the state of the IAsyncOperationWithProgress, or AsyncStatus::Started if the timeout elapsed. If the action didn't time out, then call GetResults to obtain the results of the operation. For more info, and code examples showing how to call wait_for, see Asynchronous timeouts made easy.
Interface inheritance
IAsyncOperationWithProgress
Notes to implementers
As with calling the existing methods, there are language-specific ways to define asynchronous methods that don't use IAsyncOperationWithProgress
Properties
| Name | Description |
|---|---|
| Completed |
Gets or sets the delegate that is called when the operation completes. |
| ErrorCode |
Gets a string that describes an error condition of the asynchronous operation. (Inherited from IAsyncInfo) |
| Id |
Gets the handle of the asynchronous operation. (Inherited from IAsyncInfo) |
| Progress |
Gets or sets the method that handles progress notifications. |
| Status |
Gets a value that indicates the status of the asynchronous operation. (Inherited from IAsyncInfo) |
Methods
| Name | Description |
|---|---|
| Cancel() |
Cancels the asynchronous operation. (Inherited from IAsyncInfo) |
| Close() |
Closes the asynchronous operation. (Inherited from IAsyncInfo) |
| GetResults() |
Returns the results of the operation. |