EnhancedFileSystemWatcher (#86)

This commit is contained in:
Stef Heyenrath
2018-02-03 23:22:29 +01:00
parent 180526c8b4
commit b248c8c6e5
14 changed files with 213 additions and 119 deletions

View File

@@ -0,0 +1,29 @@
using System.IO;
using System.Threading;
namespace WireMock.Util
{
internal static class FileHelper
{
private const int NumberOfRetries = 3;
private const int DelayOnRetry = 500;
public static string ReadAllText(string path)
{
for (int i = 1; i <= NumberOfRetries; ++i)
{
try
{
return File.ReadAllText(path);
}
catch
{
// You may check error code to filter some exceptions, not every error can be recovered.
Thread.Sleep(DelayOnRetry);
}
}
throw new IOException();
}
}
}