[xharness] Try and fix some strange file sharing exceptions.

This commit is contained in:
Rolf Bjarne Kvinge 2016-06-14 13:25:38 -07:00
Родитель 4bad2c1485
Коммит fdf2bd5d7b
1 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -8,16 +8,24 @@ namespace xharness
public string Description;
public string Path;
void Write (string value)
{
lock (this) {
using (var str = new FileStream (Path, FileMode.Append, FileAccess.Write, FileShare.Read)) {
using (var writer = new StreamWriter (str))
writer.Write (value);
}
}
}
public void WriteLine (string value)
{
lock (this)
File.AppendAllText (Path, value + "\n");
Write (value + "\n");
}
public void WriteLine (string format, params object [] args)
{
lock (this)
File.AppendAllText (Path, string.Format (format, args) + "\n");
Write (string.Format (format, args) + "\n");
}
}