IAsyncInfo IAsyncInfo IAsyncInfo IAsyncInfo Interface

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

Syntax

Declaration

public interface IAsyncInfopublic interface IAsyncInfoPublic Interface IAsyncInfopublic interface IAsyncInfo

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 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 summary

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

Gets the handle of the asynchronous operation.

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

Methods summary

Cancels the asynchronous operation.

Closes the asynchronous operation.

Properties

  • ErrorCode
    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 Exceptionpublic HResult ErrorCode { get; }

    Property Value

    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:

  • Id
    Id
    Id
    Id

    Gets the handle of the asynchronous operation.

    public uint Id { get; }public uint Id { get; }Public ReadOnly Property Id As uintpublic uint Id { get; }

    Property Value

    • uint
      uint
      uint
      uint

      The handle of the asynchronous operation.

  • Status
    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 AsyncStatuspublic AsyncStatus Status { get; }

    Property Value

    • 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.

Methods

  • Cancel()
    Cancel()
    Cancel()
    Cancel()

    Cancels the asynchronous operation.

    public void Cancel()public void Cancel()Public Function Cancel() As voidpublic void Cancel()
  • Close()
    Close()
    Close()
    Close()

    Closes the asynchronous operation.

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

    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.)

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.FoundationContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.GuidAttribute

Details

Assembly

Windows.Foundation.dll