SoapHttpClientProtocol 线程安全吗?

发布于 2024-08-15 04:12:10 字数 163 浏览 1 评论 0原文

我使用 VS 2008 (c#) 的“添加 Web 引用”功能创建了一个 Web 服务代理。

生成的类派生自 SoapHttpClientProtocol

我可以在单例中仅存储代理的一个实例吗?它是线程安全的吗?调用之间是否存在会阻止我执行此操作的状态?

I created a Web Service proxy with the "add web reference" feature of VS 2008 (c#).

The generated class derives from SoapHttpClientProtocol

Can I store only one instance of my proxy in a singleton? Is it thread safe? Is there state between calls that would prevent me from doing this?

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

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

发布评论

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

评论(4

垂暮老矣 2024-08-22 04:12:10

MSDN 说 SoapHttpClientProtocol 是线程安全的:

线程安全

此类型是线程安全的。

对于另一个类,例如 System. MSDN 说,Windows.Forms 不是线程安全的,

线程安全

此类型的任何公共静态(在 Visual Basic 中共享)成员都是
线程安全。不保证任何实例成员都是线程
安全。


这是一个Microsoft/MSDN 员工 表示(尽管不能保证)它是线程安全的:

嗨,麦克斯,

对于Web服务代理,我认为它应该像.NET一样是线程安全的
生成的代理类派生自“SoapHttpClientProtocol”
在文档中标记为线程安全的类:

SoapHttpClientProtocol 类

http:// /msdn.microsoft.com/en-us/library/system.web.services.protocols.soaphttpclientprotocol(VS.71).aspx

因此,只要在多线程上下文中使用它应该是安全的
因为您没有在中手动添加任何上下文相关成员
派生代理类。你也这么认为吗?

真诚的,

郑文杰

Microsoft MSDN 在线支持主管

本帖子“按原样”提供,不提供任何保证,并且不授予任何保证
权利。

MSDN says that SoapHttpClientProtocol is thread safe:

Thread Safety

This type is thread safe.

For another class like System.Windows.Forms which isn't thread-safe, MSDN says,

Thread Safety

Any public static (Shared in Visual Basic) members of this type are
thread safe. Any instance members are not guaranteed to be thread
safe.


Here is a Microsoft/MSDN employee saying (though without guarantee) that it is thread-safe:

Hi Max,

For the webservice proxy, I think it should be thread-safe as the .NET
generated proxy class is derived from the "SoapHttpClientProtocol"
class which is marked as thread-safe in document:

SoapHttpClientProtocol Class

http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soaphttpclientprotocol(VS.71).aspx

therefore, it should be safe to use it in multi-thread context as long
as you haven't manually add any context-sensitive member in the
derived proxy class. Do you think so?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no
rights.

紫轩蝶泪 2024-08-22 04:12:10

不,它不是线程安全的。客户端必须处于 Open 状态才能启用呼叫。一个简单的场景是,一个线程执行 client.Close(),而另一个线程尝试调用方法将会失败。

No. It is not thread safe. the client must be in the Open state to enable calls. A simple scenario where one thread does client.Close() while another tries to call a method will fail.

爱,才寂寞 2024-08-22 04:12:10

根据此链接:http://msdn。 microsoft.com/en-us/library/system.web.services.protocols.soaphttpclientprotocol.aspx

在“线程安全”底部,它表示此类型是线程安全的。然而我不知道将它用作单例将是线程安全的。

Per this link: http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soaphttpclientprotocol.aspx

at the bottom under 'thread safety' it says this type is thread safe. I do however not know that using it as a Singleton will be Thread safe.

行雁书 2024-08-22 04:12:10

MSDN 没有提及它是线程安全:

线程安全

此类型是线程安全的。

该类是安全的,没有提及该对象。

但可以肯定地说,它不是线程安全的 - .NET 库中没有对象是线程安全的。

(至少我没见过)

MSDN makes no mention that it's thread safe:

Thread Safety

This type is thread safe.

The class is safe, no mention of the object.

But it is safe to say that that it's not thread safe - no object in the .NET library is thread safe.

(At least i've never seen one)

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