コード例 #1
0
 public static void MakeCallWithReconnect(this INftClient nftClient, Action <IApplication> call, int retryCount)
 {
     try
     {
         call(nftClient.GetApplication());
     }
     catch (Exception ex) when(IsDisconnectedException(ex))
     {
         nftClient.Connect();
         if (retryCount <= 1)
         {
             call(nftClient.GetApplication());
         }
         else
         {
             MakeCallWithReconnect(nftClient, call, retryCount - 1);
         }
     }
 }
コード例 #2
0
 public static T MakeCallWithReconnect <T>(this INftClient nftClient, Func <IApplication, T> call, int retryCount)
 {
     try
     {
         return(call(nftClient.GetApplication()));
     }
     catch (Exception ex) when(IsDisconnectedException(ex) || ex is TimeoutException)
     {
         nftClient.Connect();
         if (retryCount <= 1)
         {
             return(call(nftClient.GetApplication()));
         }
         else
         {
             return(MakeCallWithReconnect(nftClient, call, retryCount - 1));
         }
     }
 }