Proper way to dispose a BitmapSource

喜夏-厌秋 提交于 2019-12-29 01:35:10

问题


How are you supposed to dispose of a BitmapSource ?

// this wont work because BitmapSource doesnt implement IDisposable
using(BitmapSource bitmap = new BitmapImage(new Uri("myimage.png")))
{
}

回答1:


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.



来源:https://stackoverflow.com/questions/1591996/proper-way-to-dispose-a-bitmapsource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!