在常规桌面应用程序中使用WebClient类时,我可以使用in using语句来确保清理网络资源:
using(Webclient wb = new WebClient())
{
}然而,在Silverlight中,我不能这样做,因为WebClient不是IDisposable。
1)为什么WebClient在silverlight中不是IDisposable?
2)有没有其他方法可以确保清理网络资源?
发布于 2011-05-09 20:09:09
silverlight WebClient不实现IDisposable的原因是它只支持异步操作。由于您不能正确地将异步操作包含在using语句中,因此支持using将是毫无意义的。
您可以使用CancelAsync方法终止任何不再需要的未完成的操作。
https://stackoverflow.com/questions/5928859
复制相似问题