Passing references to create_task

Don't do that unless you guarantee the object passed will survive the create_task call. Which means it's either a global variable or static or the class that contains this object is either global or static etc.
If you do this will result in access violation error.

Example:

void SomePage::OnBackRequested(Object ^ sender, BackRequestedEventArgs ^args)
{
auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
if (rootFrame != nullptr)
{
if (rootFrame->CanGoBack && !args->Handled)
{
args->Handled = true;
auto previousPage = rootFrame->BackStack->GetAt(rootFrame->BackStack->Size - 1)->SourcePageType;
wizardSteps.previousPage(context, previousPage);
rootFrame->GoBack();
}
}
}
// Here you can pass a reference
void WizardSteps::previousPage(BackupDwarf::NavigationContext ^ context, const Windows::UI::Xaml::Interop::TypeName& currentPage)
{
create_task(previousPageAsync(context, currentPage));
}
// Here you cannot pass a reference and must pass a value as the value will be passed to a co_routine.
task<void> WizardSteps::previousPageAsync(BackupDwarf::NavigationContext ^ context, const Windows::UI::Xaml::Interop::TypeName currentPage)
{
co_await handlePreviousFromAsync(context, currentPage);
setStepToPreviousPage(currentPage);
co_await handlePreviousToAsync(context);

co_return;
}