I​Async​Info I​Async​Info I​Async​Info Interface

Definition

Supports asynchronous actions and operations. IAsyncInfo is a base interface for IAsyncAction, IAsyncActionWithProgress;, IAsyncOperation; and IAsyncOperationWithProgress;, each of which support combinations of return type and progress for an asynchronous method.

public interface IAsyncInfopublic interface IAsyncInfoPublic Interface IAsyncInfo
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.FoundationContract (introduced v1)

Remarks

IAsyncInfo is an inherited interface for each of the 4 Windows Runtime interfaces that are used for asynchronous method support. These are:

When you use asynchronous methods in your app code, you usually don't see any of these interfaces as the return value. That's because you almost always use the language-specific awaitable syntax, which handles the interfaces internally. For more info, see Asynchronous programming, or one of the language-specific guides to Windows Runtime asynchronous programming (Call asynchronous APIs in C# or Visual Basic, C++, JavaScript).

For most app code, it's uncommon to use IAsyncInfo as an API even if you don't use an awaitable syntax. Each of the languages has extension points that are generally easier to use than is the Windows Runtime@Windows.Foundation.IAsyncInfo?text=IAsyncInfo interface. JavaScript has the then/done syntax. .NET has the AsTask extension method, and once the IAsyncAction is converted to a Task, it's easier to cancel, get notification on completion, and so on. For C++/CX, you can wrap the calls using the Concurrency runtime. In other words, IAsyncInfo is runtime-level infrastructure, which each of the languages use as a framework to support awaitable syntax in their own way.

If you're implementing a custom action or custom operation (an advanced scenario) don't implement IAsyncAction directly. Implement one of the 4 interfaces previously listed instead.

Properties

ErrorCode ErrorCode ErrorCode

Gets a string that describes an error condition of the asynchronous operation.

public HResult ErrorCode { get; }public Exception ErrorCode { get; }Public ReadOnly Property ErrorCode As Exception
Value
HResult HResult HResult

The error string.

Attributes

Remarks

Error codes are exposed as different types depending on the programming language you are using. Similarly, each language has different techniques for wrapping asynchronous method calls so that error conditions or cancellation can be handled. For more info see one of these topics:

See Also

Id Id Id

Gets the handle of the asynchronous operation.

public unsigned short Id { get; }public uint Id { get; }Public ReadOnly Property Id As uint
Value
uint uint uint

The handle of the asynchronous operation.

Attributes

Status Status Status

Gets a value that indicates the status of the asynchronous operation.

public AsyncStatus Status { get; }public AsyncStatus Status { get; }Public ReadOnly Property Status As AsyncStatus
Value
AsyncStatus AsyncStatus AsyncStatus

The status of the operation, as a value of the enumeration. A value of Completed indicates that the method has returned. The Started value represents a transition state before any of the other 3 final results (Completed, Error, Canceled) can be determined by the method's invocation.

Attributes
See Also

Methods

Cancel() Cancel() Cancel()

Cancels the asynchronous operation.

public void Cancel()public void Cancel()Public Function Cancel() As void
Attributes

Close() Close() Close()

Closes the asynchronous operation.

public void Close()public void Close()Public Function Close() As void
Attributes

Remarks

Calling this method indicates that you have finished with the results of the operation. After calling Close, do not call the GetResults method again (each of the 4 IAsyncInfo derived interfaces have their own implementation of GetResults.)

See Also