SoapHttpClientProtocol 线程安全吗?
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
MSDN 说 SoapHttpClientProtocol 是线程安全的:
对于另一个类,例如 System. MSDN 说,Windows.Forms 不是线程安全的,
这是一个Microsoft/MSDN 员工 表示(尽管不能保证)它是线程安全的:
MSDN says that SoapHttpClientProtocol is thread safe:
For another class like System.Windows.Forms which isn't thread-safe, MSDN says,
Here is a Microsoft/MSDN employee saying (though without guarantee) that it is thread-safe:
不,它不是线程安全的。客户端必须处于 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.
根据此链接: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.
MSDN 没有提及它是线程安全:
该类是安全的,没有提及该对象。
但可以肯定地说,它不是线程安全的 - .NET 库中没有对象是线程安全的。
(至少我没见过)
MSDN makes no mention that it's 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)