How can I get a progress report from an async write to an output stream?

68 Views Asked by At

In my app, I have to write an IBuffer to an IOutputStream. I'd like to show my user the progress of this operation, so I'm trying with the following code:

auto writeOp = strm->WriteAsync(buff);
writeOp->Progress = ref new AsyncOperationProgressHandler<unsigned int, unsigned int>(
    [=](IAsyncOperationWithProgress<unsigned int, unsigned int>^ op, unsigned int progress)
{
    MyViewModel->Insert("WriteProgress", progress);
});

auto writeToFileTask = create_task(writeOp);
writeToFileTask.then([this](unsigned int c)
{
    (void)c; // Unused parameter
});

However, MyViewModel->Insert("WriteProgress", progress) is never reached when I set a breakpoint. I don't know what I'd do differently to get this to work and I can't use C++/WinRT, so, any ideas?

0

There are 0 best solutions below