我有以下任务链,我想decoder
在最后一个任务中访问变量,但在更早的任务中创建。
create_task(file->OpenReadAsync()).then([](IRandomAccessStream^ inStream) {
return BitmapDecoder::CreateAsync(inStream);
}).then([localFolder](BitmapDecoder^ decoder) {
return localFolder->CreateFileAsync("map.png", CreationCollisionOption::ReplaceExisting);
}).then([](StorageFile^ outFile) {
return outFile->OpenAsync(FileAccessMode::ReadWrite);
}).then([](IRandomAccessStream^ outFileStream) {
return BitmapEncoder::CreateAsync(BitmapEncoder::PngEncoderId, outFileStream);
}).then([](BitmapEncoder^ encoder) {
BitmapPixelFormat pixelFormat = decoder->BitmapPixelFormat; // how do I make decoder available here?
// Do stuff that uses encoder & decoder
});