Пример #1
0
 internal static FileInfoBase[] GetFilesWithRetry(this DirectoryInfoBase info)
 {
     return(OperationManager.Attempt(() =>
     {
         return info.GetFiles();
     }));
 }
Пример #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);
        }
Пример #3
0
 public static void Attempt(Action action, Func <bool> condition = null, int retries = 3, int delayBeforeRetry = 250)
 {
     OperationManager.Attempt <object>(() =>
     {
         action();
         return(null);
     });
 }
Пример #4
0
 private static void DoSafeAction(Action action)
 {
     try
     {
         OperationManager.Attempt(action);
     }
     catch
     {
     }
 }
Пример #5
0
 private static void DoSafeAction(Action action, bool ignoreErrors)
 {
     try
     {
         OperationManager.Attempt(action);
     }
     catch
     {
         if (!ignoreErrors)
         {
             throw;
         }
     }
 }
Пример #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);
     }
 }