public void Run() { try { if (_isSafetyNetRunning != true) //checking if safetynet has already been started { this.StartSafetyNet(); //watch instance numbers _isSafetyNetRunning = true; } if (_isTempCleanerRunning != true) //checking if tempcleaner has been started { TempFiles.StartTempFileWatcher(); //watch temp directory on a diff schedule _isTempCleanerRunning = true; } this._timeline = TimelineBuilder.GetLocalTimeline(); // now watch that file for changes if (timelineWatcher == null) //you can change this to a bool if you want but checks if the object has been created { _log.Trace("Timeline watcher starting and is null..."); timelineWatcher = new FileSystemWatcher(TimelineBuilder.TimelineFilePath().DirectoryName) { Filter = Path.GetFileName(TimelineBuilder.TimelineFilePath().Name) }; _log.Trace($"watching {Path.GetFileName(TimelineBuilder.TimelineFilePath().Name)}"); timelineWatcher.NotifyFilter = NotifyFilters.LastWrite; timelineWatcher.EnableRaisingEvents = true; timelineWatcher.Changed += OnChanged; } _threadJobs = new List <ThreadJob>(); //load into an managing object //which passes the timeline commands to handlers //and creates a thread to execute instructions over that timeline if (this._timeline.Status == Timeline.TimelineStatus.Run) { RunEx(this._timeline); } else { if (MonitorThread != null) { MonitorThread.Abort(); MonitorThread = null; } } } catch (Exception e) { _log.Error($"Orchestrator.Run exception: {e}"); } }
public void Run() { try { this.StartSafetyNet(); //watch instance numbers TempFiles.StartTempFileWatcher(); //watch temp directory on a diff schedule this._timeline = TimelineBuilder.GetLocalTimeline(); // now watch that file for changes FileSystemWatcher timelineWatcher = new FileSystemWatcher(TimelineBuilder.TimelineFilePath().DirectoryName) { Filter = Path.GetFileName(TimelineBuilder.TimelineFilePath().Name) }; _log.Trace($"watching {timelineWatcher.Path}"); timelineWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.CreationTime | NotifyFilters.LastWrite; timelineWatcher.EnableRaisingEvents = true; timelineWatcher.Changed += new FileSystemEventHandler(OnChanged); _threadJobs = new List <ThreadJob>(); //load into an managing object //which passes the timeline commands to handlers //and creates a thread to execute instructions over that timeline if (this._timeline.Status == Timeline.TimelineStatus.Run) { RunEx(this._timeline); } else { if (MonitorThread != null) { MonitorThread.Abort(); MonitorThread = null; } } } catch (Exception e) { _log.Error($"Orchestrator.Run exception: {e}"); } }