sam
sam

Reputation: 1251

Determining error in the channel using Silverlight proxy client for WCF service

I'm creating Silverlight proxy client for WCF service using async pattern:

public class ProductService : ClientBase<IProductService> {

    public event EventHandler<DataEventArgs<Product>> GetProductCompleted;

    public void GetProductAsync(string productName) {
        IAsyncResult asyncResult = Channel.BeginGetProduct(productName, GetProductCallback, null);
    }

    private void GetProductCallback(IAsyncResult asyncResult) {
        Product product = Channel.EndGetProduct(asyncResult);
        if (GetProductCompleted != null)
            GetProductCompleted(this, new DataEventArgs<Product>(product));
    }
}

How can I get know if an error occurred in the channel during performing request to the service?

Upvotes: 1

Views: 184

Answers (1)

AnthonyWJones
AnthonyWJones

Reputation: 189525

The EndGetProduct ought to throw the error when called, so place a try..catch around it.

Upvotes: 1

Related Questions