示例#1
0
 protected virtual void OnFileChanged(FileChangedEventArgs args)
 {
     args.FileInfo.Refresh();
     if (args.FileInfo.LastWriteTimeUtc > _lastUpdate)
     {
         _lastUpdate = args.FileInfo.LastWriteTimeUtc;
         FileChanged?.Invoke(this, args);
     }
 }
示例#2
0
        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;
            }
        }