private static void TargetFile(Action<FileInfo> block, bool create = true)
{
var targetFile = new FileInfo(Path.Combine(Path.GetTempPath(), "synchronous-file-sink.tmp"));
if (!create)
targetFile.Delete();
else
targetFile.Create().Close();
try
{
block(targetFile);
}
finally
{
//give the system enough time to shutdown and release the file handle
Thread.Sleep(500);
targetFile.Delete();
}
}