Is there a way to get error feedback on asynchronous WCF calls?

前端 未结 1 457
独厮守ぢ
独厮守ぢ 2021-01-26 09:49

I have a WCF service which works 100% in the synchronous (blocking) mode and I now need to rework a call so that it uses the async pattern.

The service uses authenticati

1条回答
  •  孤城傲影
    2021-01-26 10:33

    The server caches the exception for you and if you call the end operation completion method for your async call it will throw any exceptions that occured.

    private void go_Click(object sender, EventArgs e)
    {
        client.BeginDoMyStuff(myValue, new AsyncCallback(OnEndDoMyStuff), null);
    }
    
    public void OnEndDoMyStuff(IAsyncResult asyncResult)
    {
        this.Invoke(new MethodInvoker(delegate() { 
            // This will throw if we have had an error
            client.EndDoMyStuff(asyncResult);
        }));
    }
    

    0 讨论(0)
提交回复
热议问题