Skip to content

Instantly share code, notes, and snippets.

@peteraritchie
Created February 9, 2012 16:38
Show Gist options
  • Save peteraritchie/1780980 to your computer and use it in GitHub Desktop.
Save peteraritchie/1780980 to your computer and use it in GitHub Desktop.
fun with WCF
var client = new ServiceReference1.Service1Client();
var retried = 0;
bool succeeded = false;
while (!succeeded)
{
if(retried > 42) throw new InvalidOperationException("Math is too hard.");
try
{
var result = client.GetData(42);
succeeded = true;
}
catch(TimeoutException timeoutException)
{
// logging... ?
}
catch (CommunicationException communicationException)
{
// logging... ?
}
finally
{
if (client.State == CommunicationState.Faulted)
{
client.Abort();
client = new ServiceReference1.Service1Client();
}
}
if (succeeded) break;
retried++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment