You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default co_await IAsyncXxx resumes in the same COM apartment. Sometimes, this is not desirable behavior. In C#, you can use ConfigureAwait(false) to disable the resume-in-same-apartment behavior. C++/WinRT would benefit from having a corresponding capability.
A wil-based version was implemented in microsoft/wil#325 but @kennykerr allowd this to be added to core C++/WinRT since it greatly simplifies the implementation, and prevents it from falling out of sync.
Reproducible example
#include<winrt/Windows.Foundation.h>usingnamespacewinrt;usingnamespacewinrt::Windows::Foundation;extern IAsyncAction Something();
IAsyncAction Example()
{
// This co_await resumes in the same apartment.co_awaitSomething();
// This co_await is permitted to resume in any apartment.co_awaitwinrt::resume_agile(Something());
}
Additional comments
The name resume_agile is up for debate, as is the preference for a free function or a member function. See the PR for details.