Calling end invoke on an asynchronous call when an exception has fired in WCF.
Posted
by james.ingham
on Stack Overflow
See other posts from Stack Overflow
or by james.ingham
Published on 2010-03-13T02:04:17Z
Indexed on
2010/03/13
2:07 UTC
Read the original article
Hit count: 423
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
© Stack Overflow or respective owner