Calling end invoke on an asynchronous call when an exception has fired in WCF.
- by james.ingham
Hey,
I currently have an asynchronous call with a callback, which fires this method on completion:
private void TestConnectionToServerCallback(IAsyncResult iar)
{
bool result;
try
{
result = testConnectionDelegate.EndInvoke(iar);
Console.WriteLine("Connection made!");
}
catch (EndpointNotFoundException e)
{
Console.WriteLine("Server Timeout. Are you connected?");
result = false;
}
...
}
With the EndpointNotFoundException firing when the server is down or no connection can be made. My question is this, if I want to recall the testConnectionDelegate with some kind of re-try button, must I first call testConnectionDelegate.EndInvoke where the exception is caught?
When I do call end invoke in the catch, I get another exception on result = testConnectionDelegate.EndInvoke(iar); whenever I call this method for the second time. This is "CommunicationObjectFaultedException". I'm assuming this is because I didn't end it properly, which is what I think I have to do.
Any help would be appreciated.
Thanks
- James