Exemplo n.º 1
0
        public static string ReadAllTextWithRetryAndDelay([NotNull] IFileSystemHandler filehandler, [NotNull] string path)
        {
            Check.NotNull(filehandler, nameof(filehandler));
            Check.NotNullOrEmpty(path, nameof(path));

            for (int i = 1; i <= NumberOfRetries; ++i)
            {
                try
                {
                    return(filehandler.ReadMappingFile(path));
                }
                catch
                {
                    Thread.Sleep(DelayOnRetry);
                }
            }

            throw new IOException();
        }
Exemplo n.º 2
0
        public static bool TryReadMappingFileWithRetryAndDelay([NotNull] IFileSystemHandler handler, [NotNull] string path, out string value)
        {
            Check.NotNull(handler, nameof(handler));
            Check.NotNullOrEmpty(path, nameof(path));

            value = null;

            for (int i = 1; i <= NumberOfRetries; ++i)
            {
                try
                {
                    value = handler.ReadMappingFile(path);
                    return(true);
                }
                catch
                {
                    Thread.Sleep(DelayOnRetry);
                }
            }

            return(false);
        }