I want to dispatch a job to the UI thread, then wait for the result and use it from another thread. Like this, but co_await does not work inside the lambda:
dispatcher.RunAsync(CoreDispatcherPriority::Normal, [&]() {
auto res = co_await mStoreContext.RequestPurchaseAsync(L"");
});
Or even waiting for the whole RunAsync operation, if I could get my result out from it
That's because void
can not be used as a return value from a coroutine (I can be if you use my my library).
try returning a std::future<void>
instead:
dispatcher.RunAsync(CoreDispatcherPriority::Normal, [&]() -> std::future<void> {
auto res = co_await mStoreContext.RequestPurchaseAsync(L"");
});