Windows Communication Foundation 开发实践指南
1. 使用 Windows Communication Foundation 客户端
在使用 Windows Communication Foundation(WCF)客户端时,有几个重要的方面需要注意。
1.1 使用异步模式
对于 WCF 客户端的操作契约,建议使用异步模式。假设服务实现了如下操作契约:
[OperationContract]
string Echo(string input);
客户端使用的操作契约可以按照异步模式表达为:
[OperationContract(AsyncPattern = true)]
IAsyncResult asynchronousResult = BeginEcho(
string input,
AsyncCallback callback,
object state);
string EndEcho(
IAsyncResult asynchronousResult);
以下是使用异步模式的示例代码:
public class EchoClient: ClientBase<IEcho>: IEcho
{
public EchoClient(string endpointConfigura
超级会员免费看
订阅专栏 解锁全文
14

被折叠的 条评论
为什么被折叠?



