private void SpawnMonitorThread(Monitor monitor) { var monitorThreadStart = new ParameterizedThreadStart(this.AttatchFileCreationEventListener); var monitorThread = new Thread(monitorThreadStart); monitorThread.Start(monitor); }
private void ListenForFileCreationEvents(Monitor monitor) { var fileSystemWatcher = new FileSystemWatcher(monitor.Source) { EnableRaisingEvents = true }; fileSystemWatcher.Created += this.HandleFileCreationEvents; }
private void FileCreationHandler(Monitor monitor, FileStream fileCreated) { if (this.fileCreationEventHandlers != null && this.fileCreationEventHandlers.Count() > 0) { using (fileCreated) { foreach (var fileCreationEventHandler in this.fileCreationEventHandlers) { var filename = fileCreated.Name; var memoryStream = new MemoryStream(); fileCreated.CopyTo(memoryStream); this.SpawnFileCreationHandlerThread(fileCreationEventHandler, monitor, memoryStream, filename); } } } }
private void SpawnFileCreationHandlerThread(IFileCreationEventHandler fileCreationEventHandler, Monitor monitor, Stream fileCreated, string fileName) { var parameterizedThreadStart = new ParameterizedThreadStart(this.FileCreatedEventHandlerDelegate); var thread = new Thread(parameterizedThreadStart); thread.Start(new object[] { fileCreationEventHandler, monitor, fileCreated, fileName }); }
public void Start(Monitor monitor, Expression<Action<Monitor, FileStream>> fileCreationHandler) { this.innerMonitor = monitor; this.innerFileCreationEventHandler = fileCreationHandler; this.SpawnMonitorThread(monitor); }
public void Start(Monitor monitor, Expression <Action <Monitor, FileStream> > fileCreationHandler) { this.innerMonitor = monitor; this.innerFileCreationEventHandler = fileCreationHandler; this.SpawnMonitorThread(monitor); }