我应该使用“使用”吗? 在我的 SitkaSoapServiceClient 上?

发布于 2024-07-14 00:44:45 字数 569 浏览 6 评论 0原文

(这与 Microsoft 的 SitkaSoapService 相关,位于 https://database.windows.net/soap 的服务参考中/v1/)

我正在使用 SitkaSoapServiceClient 通过 SOAP 访问我的 SQL Data Services 数据库。

每次使用这个代理类时都应该使用“using”语句吗? 或者它是否在内部以安全的方式进行自己的连接处理?

即我需要说:

using (SitkaSoapServiceClient proxy = GetProxy())
    proxy.Update(scope, entity);

...或者可以安全地说:

GetProxy().Update(scope, entity);

[其中 GetProxy() 返回 SitkaSoapServiceClient 对象。]

(This relates to Microsoft's SitkaSoapService, in the service reference at https://database.windows.net/soap/v1/)

I'm using SitkaSoapServiceClient to access my SQL Data Services database by SOAP.

Should I use a "using" statement every time I use this proxy class? Or does it do its own connection handling in a safe way internally?

I.e. do I need to say:

using (SitkaSoapServiceClient proxy = GetProxy())
    proxy.Update(scope, entity);

... or is it safe to say:

GetProxy().Update(scope, entity);

[where GetProxy() returns a SitkaSoapServiceClient object.]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

夏日浅笑〃 2024-07-21 00:44:45

代理类代码包装在 using 语句中时是否可以编译? 如果是这样,它实现了 IDisposable,我会使用它。

编辑:如果不执行任何操作,调用 Dispose() 应该会产生很少的开销,并且如果类的设计者稍后决定分配非托管资源,您将免受泄漏。

Does the proxy class code compile when wrapped in a using statement? If so, it implements IDisposable and I'd use it.

EDIT: calling Dispose() should incur little overhead if it does nothing, and if the designer of the class decides at a later date to allocate unmanaged resources you will be protected from a leak.

寄居人 2024-07-21 00:44:45

当类实现 IDisposable 时,您应该始终使用 using,因为该类的作者告诉您它包含一些应该释放的资源。

You should always use using when the class implements IDisposable, because the author of the class tells you that it contains some resources that should be freed.

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