A 3rd party has supplied an interface which allows me to search their database for customers and retrieve their details. Eg. Pictures, date of birth etc.
I imported their WSDL into Visual Studio and am using the Async methods to retrieve the customer details.
MyClient Client = new MyClient();
Client.FindCustomersCompleted += FindCustomersCompleted;
Client.GetCustomerDetailsCompleted += GetCustomerDetailsCompleted;
Client.FindCustomersAsync("Jones");
Below are the two events which deal with the responses.
void FindCustomersCompleted(object sender, FindCustomersCompletedEventArgs e)
{
foreach(var Cust in e.Customers)
{
Client.GetCustomerDetailsAsync(Cust.ID);
}
}
void GetCustomerDetailsCompleted(object sender, GetCustomerDetailsCompletedEventArgs e)
{
// Add the customer details to the result box on the Window.
}
So lets assume that my initial search for "Jones" returns no results or causes an error. Its fairly straight forward to tell the user that there was an error or no results found as I will only receive a single response.
However if i say get 50 results for "Jones" then i make 50 GetCustomerDetailsAsync calls and get 50 responses.
Lets say that something goes wrong on the server side and i don't get any valid responses. Each GetCustomerDetailsCompleted event will receive an error/timeout and i can determine that that individual response has failed.
What is the best way to determine that All of my responses have failed and i need to inform the user that there has been a failure? Alternatively what if 1 out of 50 succeeds?
Should i keep track of my requests and flag them as successful as i receive the response?