Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

c# - Is SoapHttpClientProtocol thread safe?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...