Does anyone know about lazy stream in .net? IOW, I want to create a method like this:
public Stream MyMethod() {
return new LazyStream(...whatever parameters..., delegate() {
... some callback code.
});
}
and when my other code calls MyMethod () to return the stream, it will not actually do any work until someone really tries to read from the stream. The usual way would be to force MyMethod to take the stream parameter as a parameter, but this will not work in my case (I want to pass the returned MVC stream to FileStreamResult).
To clarify what I'm looking for, you need to create a multi-level series of transformations, so
Database result = (converted to) => byte stream = (chained to) => GZipStream = (transferred) => FileStreamResult constructor.
The result set can be huge (GB), so I don’t want to cache the result in a MemoryStream, which I can pass to the GZipStream constructor. Rather, I want to get from a result set, since GZipStream is requesting data.
source
share