gpt4 book ai didi

c# - SoapHttpClientProtocol 线程安全吗?

转载 作者:太空狗 更新时间:2023-10-29 17:42:46 27 4
gpt4 key购买 nike

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

生成的类派生自SoapHttpClientProtocol

我可以在单例中只存储一个代理实例吗?它是线程安全的吗?调用之间是否存在阻止我这样做的状态?

最佳答案

MSDN 说 SoapHttpClientProtocol是线程安全的:

Thread Safety

This type is thread safe.

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

Thread Safety

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


Here is a Microsoft/MSDN employee说(虽然没有保证)它是线程安全的:

Hi Max,

For the webservice proxy, I think it should be thread-safe as the .NETgenerated 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 longas you haven't manually add any context-sensitive member in thederived 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 norights.

关于c# - SoapHttpClientProtocol 线程安全吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1922214/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com