Search code examples
asynchronouswindows-runtimewinrt-async

Do I need to close IAsyncOperation?


In WinRT, do I need to call Close() on IAsyncOperation<T> ^ objects? Either the the operation initiating code, or in the completion handler? If not, why is it there?


Solution

  • From your syntax, you're using C++/CX.

    For C++/CX, IAsyncOperation::Close is automatically called in the destructor, so you do not need to explicitly call it.

    For JS, you must explicitly call .close().

    For C#, it's projected as IDisposable, so a using() statement is appropriate.