We have a WCF Endpoint that creates a session via a secure login.
That session will time out. When that happens, the endpoint will
throw an exception. If the .Message contains the "timeout" message,
then we know that the session needs to be re-established, by logging
in again, and then calling the method that was originally called.
There are no limitations on how many times a user can login or how
On the client side, a PCL project, iOS/Droid/Windows8/Silverlight8
targeted, is making the calls. In this case, it is being used in a
Xamarin.Forms mobile app, but we also intend to create this as a
redistributable PCL that our clients to utilize to interact with our
If the exception contains the "timeout" message, I need to re-login
and then call the method that threw the exception. What is the best
way to do this?
Turned out I was WAY over thinking this. Here it the code that
solved it. This is in a PCL, so WCF threading support is in the EAP
pattern, but I used TaskFactory and converted it to TAP, which is SO
MUCH NICER to deal with, so the TAPMethod.EAP2TAPSOMEWCFMETHOD calls a
method that does the EAP to TAP conversion.
I could have done this with Func as well, attempting to keep the
catch block generic, but since my calls have variable number of
parameters, it was just as easy to hard code the call back.
public Record SOMEWCFMETHOD(string szParam)
Task<Record > task =
catch (Exception ex)