Skip to content

Instantly share code, notes, and snippets.

@heejune
Created February 25, 2017 12:40
Show Gist options
  • Save heejune/cbb30b81da86de57a850dcc967c5f63e to your computer and use it in GitHub Desktop.
Save heejune/cbb30b81da86de57a850dcc967c5f63e to your computer and use it in GitHub Desktop.
wrl and cppwinrt combination
winrt::Windows::Foundation::IAsyncOperation<int> GetAsyncOp()
{
using namespace winrt;
using namespace Windows::Foundation;
for (int i = 0; i != 5; ++i)
{
co_await 5000ms;
}
co_return 1;
}
STDMETHODIMP DemoCore::GetCppwinrtDataAsync(::ABI::Windows::Foundation::IAsyncOperation<int>** value)
{
auto asyncOp = GetAsyncOp();
*value = reinterpret_cast<::ABI::Windows::Foundation::IAsyncOperation<int>*>(winrt::detach(asyncOp));
return S_OK;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment