从 Castle Wcf 设施异步调用获取响应
假设我有一个这样的电话:
_actService.BeginWcfCall(x => x.SaveAct(new SaveActRequest
{
Act = act
}));
如何获得 SaveAct 的响应?如何设置在操作完成时触发的回调?
我尝试过:
_actService.BeginWcfCall(x => x.GetAct(new GetActRequest
{
ActName =
saveScheduleSlotRequest.ScheduleSlot.ActProxy.Name
}), (result) =>
{
var async = (GetActResponse)result.AsyncState;
}, _actService);
但它抱怨一个不明确的调用?
有什么指点吗?
Say I have a call like so:
_actService.BeginWcfCall(x => x.SaveAct(new SaveActRequest
{
Act = act
}));
How do I get to the response of SaveAct? How can I set up a callback to fire when the operation completes?
I have tried:
_actService.BeginWcfCall(x => x.GetAct(new GetActRequest
{
ActName =
saveScheduleSlotRequest.ScheduleSlot.ActProxy.Name
}), (result) =>
{
var async = (GetActResponse)result.AsyncState;
}, _actService);
But it complains about an ambiguous call?
Any pointers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Craig Neuwirt 回答了这个问题:http://groups.google.com/ group/castle-project-users/browse_thread/thread/f440dbd05e60484f
我想您可能对正常的 C# 异步模式有点困惑。
它总是涉及一对 Begin/End 调用。
WCF 工具支持 2 个回调模型,由 BeginWcfCall 的最后 2 个参数确定。
这 2 个选项是
1)动作>,状态
2) AsyncCallback,状态
选项 1 是标准异步模式,如下所示
正如您所看到的,第一个需要引用 _actService 代理来调用结束。第一种是一种方便的方法,但没有。
选择哪种方法完全取决于您对 c#standard 异步模式的偏好。
Craig Neuwirt answered this: http://groups.google.com/group/castle-project-users/browse_thread/thread/f440dbd05e60484f
I think you may be a little confused about the normal C# async pattern.
It always involve a pair of Begin/End calls.
The WCF Facility support 2 callback models which is determined by the last 2 arguments of your BeginWcfCall
The 2 options are
1) Action>, state
2) AsyncCallback, state
Option 1 is the standard async pattern and would look like this
As you can see, the first requires a reference to the _actService proxy to call end. The first is a convenience method which does not.
The choice of which approach depends entirely on your preference of the c#standard async pattern.