假设当第一个then
子句完成时,bitmapStream
是否会因为它超出范围而被处置(从而使其引用计数变为 0)?
BitmapImage^ bmp = ref new BitmapImage();
create_task(StorageFile::GetFileFromApplicationUriAsync(uri)).then([](StorageFile^ file)
{
return file->OpenReadAsync();
}).then([bmp](IRandomAccessStream^ bitmapStream)
{
return bmp->SetSourceAsync(bitmapStream);
}).then([bmp]()
{
// Do some stuff with bmp here
});