I would like to implement an instance of IRandomAccessStream in C# (it will be returning data generated in realtime). The stream does not actually need to be writable or seekable, but I want to return my own data in the ReadAsync method (which is actually part of IInputStream).
public IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, uint count, InputStreamOptions options)
{
throw new NotImplementedException("To be done");
}
My two main questions are:
- how do I return something that implements
IAsyncOperationWithProgress? Is there anything built into the framework to help with this? - how do I write data into the buffer?
IBufferonly hasLengthandCapacityproperties (the concrete Buffer class doesn’t offer any more either).
How to Convert byte Array to IRandomAccessStream
I’ve found this blog article, hopefully this realization of
IRandomAccessStreamcan be a starting point for you.