开发者

Proper way to dispose a BitmapSource

开发者 https://www.devze.com 2022-12-09 12:05 出处:网络
How are you supposed to dispose of a BitmapSource ? // this wont work because Bitm开发者_运维技巧apSource doesnt implement IDisposable

How are you supposed to dispose of a BitmapSource ?

// this wont work because Bitm开发者_运维技巧apSource doesnt implement IDisposable
using(BitmapSource bitmap = new BitmapImage(new Uri("myimage.png")))
{
}


You do not have to Dispose() a BitmapSource. Unlike some other "image" classes in the Framework, it does not wrap any native resources.

Just let it go out of scope, and the garbage collector will free its memory.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号