当控制台应用程序进程结束时,是否所有 SPWeb 或 SPSite 实例都会自动处置?
我们有关于在 SharePoint 中使用一次性对象的最佳实践。
但我在想 - 使用控制台应用程序时我可以跳过这些吗?这是我想在该过程完成后执行一次的一些代码。 SPSite 和 SPWeb 在某处是否保持打开状态?
我为什么问这个?我只是不想在使用诸如
var lists =
from web in site.AllWebs.Cast<SPWeb>()
where web is meeting workspace && list is task list
select list
then do some stuff on lists
etc.
那里存在严重的资源泄漏之类的东西时感到压力,因为网络会被打开、过滤而不是关闭。
那么我应该担心控制台应用程序吗?
We have Best practices on using disposable object in SharePoint.
But i`m thinking - can I skip these when using Console Application? That's some code I want to execute once and after that process has finished. Do or don't SPSite and SPWeb's remain opened somwhere?
Why i`m asking this? I just don't want to stress when using something like
var lists =
from web in site.AllWebs.Cast<SPWeb>()
where web is meeting workspace && list is task list
select list
then do some stuff on lists
etc.
Some serious resource leak there because webs get opened, filtered and NOT closed.
So should I worry in console app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦您的命令行应用程序终止,其所有资源都将被释放。毕竟,命令行应用程序在单独的进程中运行。这与关闭 IIS 相同,它也将释放所有资源,无论代码忘记释放它们。
Once your command line app terminates, all its resources will be released. After all, the command line app runs in a separate process. This is the same as shutting down IIS, which will also release any resources regardless of the code that forgot to dispose of them.