WCF 服务 aync 模式反馈失败的传输
我正在 Silverlight 4 中工作,并使用用于更新客户端的异步模式实现轮询双工服务。
// interface for messages back to client
[OperationContract(IsOneWay = true, AsyncPattern=true)]
IAsyncResult BeginSendMessage(byte[] MessageData, AsyncCallback callback, object State);
void EndSendMessage(IAsyncResult result);
我使用定义的 RequestState 对象对客户端进行回调,以跟踪我发送到的连接客户端。
AsyncCallback callback = new AsyncCallback(this.MessageSent);
RequestState state = new RequestState { ConnectionNo = connectionno};
client.BeginSendMessage(MessageData, callback, state);
我没有看到任何方法可以使用回调中返回的 IAsyncResult 参数来检查错误。
那么我的问题是,如何判断消息是否发送失败?
I am working in Silverlight 4 and implementing a Polling Duplex service with an asynchronous pattern used to update the clients.
// interface for messages back to client
[OperationContract(IsOneWay = true, AsyncPattern=true)]
IAsyncResult BeginSendMessage(byte[] MessageData, AsyncCallback callback, object State);
void EndSendMessage(IAsyncResult result);
I make the call back to the client using a RequestState object I defined to keep track of which connected client I sent to.
AsyncCallback callback = new AsyncCallback(this.MessageSent);
RequestState state = new RequestState { ConnectionNo = connectionno};
client.BeginSendMessage(MessageData, callback, state);
I don't see any way to check for an error using the IAsyncResult parameter that is given back in the callback.
So my question is, how can I tell if the message fails to be sent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢这篇文章的帮助,我找到了自己问题的答案 有没有办法获得异步 WCF 调用的错误反馈? :)
当回调返回时,我使用状态对象中传递的 ConnectionNo 再次在连接列表中找到该连接。
然后我打电话
I found the answer to my own question thanks to the help in this post Is there a way to get error feedback on asynchronous WCF calls? :)
When the callback returns, I find the connection in my connection list again using the ConnectionNo I passed through in the state object.
I then call