ファイルを監視して、ファイルが成長していないことを確認したい。外部プログラムを実行します
Process.Start(
"procdump.exe",
string.Format(@"-ma {0} Output\{1}_RAW_DUMP.dump",
processName,
dt.ToString("yyyyMMdd-HHmmss")));
そして、このプロセスがいつ終了したかを知る必要があります。
だから私はこれを書いた:
private void CheckDumpFile(DateTime startDateTime, IConfigHolder configHolder, List<string> results)
{
var path = CheckExistensDumpFile(startDateTime);
const int delayMs = 250;
if (path == null)
{
Console.WriteLine("Dumpfile not ready yet, next try in 0.25s, now: {0}", DateTime.Now.ToString("HH:mm:ss.fff"));
RetryAction(() => CheckDumpFile(startDateTime, configHolder, results), delayMs);
}
else
{
var fileInfo = new FileInfo(path);
if (fileInfo.Length == 0)
{
Console.WriteLine("Dumpfile has no Length yet, now: {0}", DateTime.Now.ToString("HH:mm:ss.fff"));
RetryAction(() => CheckDumpFile(startDateTime, configHolder, results), delayMs);
}
else
{
if (_lastLength == fileInfo.Length)
{
Console.WriteLine("Dumpfile is " + _lastLength + "bytes, starting analysis, now: {0}", DateTime.Now.ToString("HH:mm:ss.fff"));
ReadDumpFile(configHolder, path, results);
}
else
{
Console.WriteLine("Dumpfile is still growing, next try in 0.25s, now: {0}", DateTime.Now.ToString("HH:mm:ss.fff"));
_lastLength = fileInfo.Length;
RetryAction(() => CheckDumpFile(startDateTime, configHolder, results), delayMs);
}
}
}
}
この
public static void RetryAction(Action action, int delayMs)
{
new Timer(obj => action(), null, delayMs, Timeout.Infinite);
}
これは、ファイルが遅くなるまで機能し、「RetryAction」の呼び出しがさらにいくつかあります。1回も電話が返ってこない。
何が問題のように見えるか知っていますか?私の場合、より良い解決策はありますか?FileWatcher は ne9twork 共有ではひどいと誰かが私に言ったので、私は FilWatcher を無視しました。