Created
February 9, 2012 16:38
-
-
Save peteraritchie/1780980 to your computer and use it in GitHub Desktop.
fun with WCF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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