Merge pull request #7144 from ivandrofly/feature/save-retry

Replace magic numbers with named constants
This commit is contained in:
Nikolaj Olsson 2023-07-23 09:55:30 -04:00 committed by GitHub
commit 0719c7e412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -225,7 +225,9 @@ namespace UpdateAssemblyInfo
private static void SaveWithRetry(string fileName, string content) private static void SaveWithRetry(string fileName, string content)
{ {
for (int i = 0; i < 10; i++) const int maxRetries = 10;
var delayBetweenRetries = TimeSpan.FromMilliseconds(10);
for (var i = 0; i <= maxRetries; i++)
{ {
try try
{ {
@ -234,10 +236,14 @@ namespace UpdateAssemblyInfo
} }
catch catch
{ {
System.Threading.Thread.Sleep(10); if (i == maxRetries)
{
throw;
}
System.Threading.Thread.Sleep(delayBetweenRetries);
} }
} }
File.WriteAllText(fileName, content, Encoding.UTF8);
} }
private static void GetRepositoryVersions(out VersionInfo currentRepositoryVersion, out VersionInfo latestRepositoryVersion) private static void GetRepositoryVersions(out VersionInfo currentRepositoryVersion, out VersionInfo latestRepositoryVersion)

View File

@ -109,7 +109,7 @@ namespace UpdateLanguageFiles
throw; throw;
} }
System.Threading.Thread.Sleep(10); System.Threading.Thread.Sleep(delayBetweenRetries);
} }
} }
} }