protected virtual void OnFileChanged(FileChangedEventArgs args) { args.FileInfo.Refresh(); if (args.FileInfo.LastWriteTimeUtc > _lastUpdate) { _lastUpdate = args.FileInfo.LastWriteTimeUtc; FileChanged?.Invoke(this, args); } }
private async Task CheckFileLock(int delay) { while (true) { if (FileUtils.IsFileLocked(_fileInfo)) { if (delay > MaxDelay) { var args = new FileChangedEventArgs(_fileInfo, false); OnFileChanged(args); break; } await Task.Delay(delay); delay = delay * 2; continue; } var arg = new FileChangedEventArgs(_fileInfo, true); OnFileChanged(arg); break; } }