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?
The EndGetProduct
ought to throw the error when called, so place a try..catch
around it.