Created
June 18, 2018 15:06
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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