当控制台应用程序进程结束时,是否所有 SPWeb 或 SPSite 实例都会自动处置?

发布于 2024-09-01 08:54:11 字数 529 浏览 4 评论 0原文

我们有关于在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

翻身的咸鱼 2024-09-08 08:54:11

一旦您的命令行应用程序终止,其所有资源都将被释放。毕竟,命令行应用程序在单独的进程中运行。这与关闭 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文