WCF 服务 aync 模式反馈失败的传输

发布于 2024-09-14 02:25:43 字数 685 浏览 3 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贪恋 2024-09-21 02:25:43

感谢这篇文章的帮助,我找到了自己问题的答案 有没有办法获得异步 WCF 调用的错误反馈? :)

当回调返回时,我使用状态对象中传递的 ConnectionNo 再次在连接列表中找到该连接。

然后我打电话


    try
    {
        //This is the method that is defined in my ServiceContract to complete the AsyncPattern
        client.EndSendMessage(asyncresult);
    }
    catch
    {
        //code here to notify the server that there was an error sending the message
    }

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


    try
    {
        //This is the method that is defined in my ServiceContract to complete the AsyncPattern
        client.EndSendMessage(asyncresult);
    }
    catch
    {
        //code here to notify the server that there was an error sending the message
    }

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文