WCF 异步服务代理。是否“EndXXX”?关闭连接?
我目前正在隔离 WCF Web 服务的接口定义,并对客户端进行排序以依赖于这些接口而不是生成的服务客户端类。
当前使用的模式是这样的 -
var client = new ServiceClient();
client.DoSomethingCompleted += (o,args) =>
{
client.CloseAsync();
//Do Something
}
client.DoSomething();
漂亮又简单。客户端返回后,立即关闭连接。
通过依赖代理的接口,您会失去生成的事件,并且必须使用异步开始/结束模式。现在它会读到 -
//client is now an IDoSomethingable
client.BeginDoSomething(new AsyncCallback((result) =>
{
var somethingDone = client.EndDoSomething(result);
}),null);
所以我的问题是当调用“EndDoSomething”时客户端是否会关闭还是我错过了一些东西,因为似乎没有明确的方法来关闭它。
非常感谢。
I'm currently segregating the interface definition of a WCF web service and sorting out the client to depend on these interfaces rather than the generated service client class.
The pattern that's currently being used reads like this -
var client = new ServiceClient();
client.DoSomethingCompleted += (o,args) =>
{
client.CloseAsync();
//Do Something
}
client.DoSomething();
Nice and simple. As soon as the client returns, close the connection.
By depending on the interface of the proxy you lose out on the generated events and have to use the Async Begin/End pattern. Now it would read -
//client is now an IDoSomethingable
client.BeginDoSomething(new AsyncCallback((result) =>
{
var somethingDone = client.EndDoSomething(result);
}),null);
So my question is does the client get closed when 'EndDoSomething' is called or am I missing something since there doesn't appear to be an explicit way to close it.
Much thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论