清除窗口电话 7 中的缓存 [英] clear cache in window phone 7
问题描述
我想在 window phone 7 中使用 Dipose 缓存.在我的项目中,我下载了图片,使用后我通过以下方式处理图片:
I want Dipose cache in window phone 7. In my project I have download Images, after use I Dispose Image by:
Image.source = null;
Image = null;
但记忆没有恢复原状,例如:
but memory does not return to its original, for example:
下载后我设置了图片来源:
After download I set source of image :
img.source = new bitmapImage(new uri("http://diadiem.com/image/123.jpg"),UriKind.Relative);
当下一页或再次加载页面时:我想清除旧项目,并在缓存中释放内存.虽然我尝试设置image.source= null
,并设置控制Image = null
.但是记忆并没有回到原来的样子.
When next Page or LoadPage Again: I want clear item old item, and Replease memory in cache.
Although I tried set image.source= null
, and set control Image = null
. But memory does not return to its original.
请帮帮我!
推荐答案
要从缓存中删除下载的图像,您需要将其源分配给单独的 BitmapImage
并在设置之前将其设置为 null图像的来源为空.
To remove a downloaded image from the cache you need to assign it's source to a separate BitmapImage
and set that to null before setting the image's source to null.
BitmapImage bitmapImage = image.Source as BitmapImage;
bitmapImage.UriSource = null;
image.Source = null;
不要问我为什么,但它有效.
Don't ask me why, but it works.
这篇关于清除窗口电话 7 中的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!