WCFサービスの障害のある伝送に関するAYNCパターンフィードバック
-
28-09-2019 - |
質問
私は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パラメーターを使用してエラーを確認する方法はありません。
それで、私の質問は、メッセージが送信されないかどうかをどのように見分けることができますか?
解決
この投稿のヘルプのおかげで、自分の質問に対する答えを見つけました 非同期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
}
所属していません StackOverflow