Skip to content

Instantly share code, notes, and snippets.

@Tryum
Created June 18, 2018 15:06
Show Gist options
  • Save Tryum/30d536f2af8f4a15190dacfefb45b5ba to your computer and use it in GitHub Desktop.
Save Tryum/30d536f2af8f4a15190dacfefb45b5ba to your computer and use it in GitHub Desktop.
Calling co_await on an IAsyncAction with a Completed handler attached throws a hresult_illegal_delegate_assignment
#pragma comment(lib, "windowsapp")
#include <chrono>
#include <winrt/base.h>
using namespace std::chrono_literals;
using namespace winrt;
using namespace winrt::Windows::Foundation;
IAsyncAction foo()
{
co_await 1ms;
}
IAsyncAction bar(IAsyncAction& asyncAction)
{
co_await asyncAction;
}
int main()
{
init_apartment();
auto fooAction = foo();
fooAction.Completed([](IAsyncAction const& sender, AsyncStatus status)
{
});
auto barAction = bar(fooAction);
barAction.get();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment