1

私は Silverlight 4 で作業しており、クライアントの更新に使用される非同期パターンを使用して Polling Duplex サービスを実装しています。


    // 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 パラメータを使用してエラーをチェックする方法がわかりません。

私の質問は、メッセージの送信に失敗したかどうかをどのように確認できますか?

4

1 に答える 1

0

この投稿の助けを借りて、自分の質問に対する答えを見つけました。非同期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
    }

于 2010-08-13T16:21:22.553 に答える