Let's say I have a function that I call on the UI thread:
IAsyncOperation<BitmapImage^>^ GetImage()
{
return create_async([]
{
return create_task(GetStreamAsync())
.then([] (Stream^ stream)
{
auto image = ref new BitmapImage();
// set image properties.
image.SetSourceAsync(stream);
return image;
});
});
}
I know the inner task will also execute on the UI thread since this question's answer indicates an apartment aware task continues in its apartment by default.
But when is the execution of the create_task body scheduled? Does it end up happening synchronously? Or does the UI thread wait until it has free cycles to process the async logic?