I\'m trying to use the Caching Application Block to cache some images (these images take a long time to render)
BitmapSource bitmapSource; ///some bitmap s
The problem is that the stream is closed (via Dispose()
) at the end of the using
block. You retain a reference to the closed stream.
Instead, save the contents of the stream to your cache:
_cache.Add(someId, stream.ToArray());
When you call the PngBitmapDecoder
constructor, you'll have to create a new MemoryStream
to read from that byte array.