You'll need to return your own IAsyncOperationWithProgress
. You can use AsyncInfo.Run
to do that:
public IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, uint count, InputStreamOptions options)
{
return AsyncInfo.Run<IBuffer, uint>(async (token, progress) =>
{
progress.Report(0);
await _stream.ReadAsync(buffer, count, options);
progress.Report(50);
// call _cipher.ProcessBytes(...)
progress.Report(100);
return buffer;
});
}
Of course you could make your own progress reporting more granular depending on what you are doing.
To access data in IBuffer
you can use either ToArray
or AsStream
extension method.