Partager via


IAsyncOperation<TResult> interface

Represents an asynchronous operation that returns a result.

Template parameters

  • TResult
    The type that encapsulates the result from the asynchronous operation.

Members

The IAsyncOperation<TResult> interface inherits from IAsyncInfo. IAsyncOperation also has these types of members:

  • Methods

Methods

The IAsyncOperation<TResult> interface has these methods.

Method Description
get_Completed

Gets the method that is called when the asynchronous operation completes.

GetResults

Gets the outcome of the asynchronous operation.

put_Completed

Sets the method that is called when the asynchronous action completes.

 

Remarks

The IAsyncOperation<TResult> interface represents an asynchronous operation that returns a result and does not have progress notifications. When the operation completes, the IAsyncOperationCompletedHandler<TResult> specified by get_Completed is invoked. The GetResults method receives a pointer to the task results (TResult) of the operation.

Use the Task type provided in the Parallel Patterns Library (ppltasks.h) for asynchronous operations in your own app. For managed code, consider using the await keyword instead of directly using this interface.

IAsyncOperation<T> myAsyncOp = MyObj.SomePublicAsyncMethod();

myAsyncOp.Completed = (op) => {
  // ...
  T myResults = op.GetResults();
  // ...
};

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Header

Windows.Foundation.Collections.h

See also

IAsyncInfo

IAsyncOperationCompletedHandler<TResult>