public void Change(IFileSystemEvent @event) { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } Logger.LogInformation(Thread.CurrentThread.ManagedThreadId + ": Change id " + @event.Id + " + itemId: " + @event.ItemId + " parentId: " + @event.ParentId + " type: " + @event.Type + " oldName: " + @event.OldName); Hub.Clients.All.SendAsync(nameof(Change), @event.Id, @event.ItemId, @event.ParentId, @event.Type, @event.CreationTimeUtc, @event.OldName); }
private Task OnRemovedAsync(IFileSystemEvent e, CancellationToken token) { lock (_filesWaitingToRemove) { if (_filesWaitingToRemove.Contains(e.FullName)) { _filesWaitingToRemove.Remove(e.FullName); _nonQuietOutput.AddInformationMessage(DateTime.UtcNow, $"Found removed file: {e.FullName}", token); } } return(Task.CompletedTask); }
private static Task OnTouchedAsync(IFileSystemEvent fse, CancellationToken token) { Console.WriteLine($"[{fse.DateTimeUtc:HH:mm:ss.ffff}]:[{fse.FileSystemInfo.FullName}"); var rng = new Random(); if (rng.Next(100) == 0) { Console.WriteLine("Calling STOP in loop - Start!"); Watcher.Stop(); Console.WriteLine("Calling STOP in loop - End!"); } return(Task.CompletedTask); }
private Task OnAddedAsync(IFileSystemEvent e, CancellationToken token) { lock (_filesWaitingToAdd) { if (_filesWaitingToAdd.Contains(e.FullName)) { _filesWaitingToAdd.Remove(e.FullName); try { File.Delete(e.FullName); } catch { // ignore } _nonQuietOutput.AddInformationMessage(DateTime.UtcNow, $"Found added file: {e.FullName}", token); } } return(Task.CompletedTask); }
private async Task OnTouchedAsync(IFileSystemEvent fse, CancellationToken token) { await AddMessage(ConsoleColor.Gray, fse.DateTimeUtc, $"[{(fse.IsFile?"F":"D")}][T]:{fse.FileSystemInfo.FullName}", token).ConfigureAwait(false); }
private Task OnRemovedAsync(IFileSystemEvent fse, CancellationToken token) { _output.AddWarningMessage(fse.DateTimeUtc, $"[{(fse.IsFile ? "F" : "D")}][-]:{fse.FileSystemInfo.FullName}", token); return(Task.CompletedTask); }