Beispiel #1
0
 internal static FileInfoBase[] GetFilesWithRetry(this DirectoryInfoBase info)
 {
     return(OperationManager.Attempt(() =>
     {
         return info.GetFiles();
     }));
 }
Beispiel #2
0
        private const int DefaultDelayBeforeRetry = 250; // 250 ms

        public static void Attempt(Action action, int retries = DefaultRetries, int delayBeforeRetry = DefaultDelayBeforeRetry)
        {
            OperationManager.Attempt <object>(() =>
            {
                action();
                return(null);
            }, retries, delayBeforeRetry);
        }
Beispiel #3
0
 public static void Attempt(Action action, Func <bool> condition = null, int retries = 3, int delayBeforeRetry = 250)
 {
     OperationManager.Attempt <object>(() =>
     {
         action();
         return(null);
     });
 }
Beispiel #4
0
 private static void DoSafeAction(Action action)
 {
     try
     {
         OperationManager.Attempt(action);
     }
     catch
     {
     }
 }
Beispiel #5
0
 private static void DoSafeAction(Action action, bool ignoreErrors)
 {
     try
     {
         OperationManager.Attempt(action);
     }
     catch
     {
         if (!ignoreErrors)
         {
             throw;
         }
     }
 }
Beispiel #6
0
 // we cannot use FileSystemHelpers.DeleteFileSafe.
 // it does not handled IOException due to 'file in used'.
 private void DeleteFileSafe()
 {
     // Only clean up lock on Windows Env
     try
     {
         FileSystemHelpers.DeleteFile(_path);
         OperationManager.Attempt(() =>
                                  // throws exception if file is still present
                                  TryRemovedLockFile()
                                  , 10, 250);
     }
     catch (Exception ex)
     {
         TraceIfUnknown(ex);
     }
 }