protected override void OnDoWork(DoWorkEventArgs e) { base.OnDoWork(e); MonitorStarted?.Invoke(this, new EventArgs()); bool _requestCancellation; var output = string.Empty; do { MonitorCycleStarted?.Invoke(this, new EventArgs()); #region Update Monitor Output var reader = new StreamReader( new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); while (!reader.EndOfStream) { liveLines.Enqueue(reader.ReadLine()); while (liveLines.Count > Properties.Settings.Default.MaxDisplayedLines) { liveLines.Dequeue(); } } var sb = new StringBuilder(); for (int i = 0; i < liveLines.Count; i++) { var line = liveLines.Dequeue(); sb.AppendLine(line); liveLines.Enqueue(line); } var formatted = sb.ToString(); if (output != formatted) { output = formatted; OutputUpdate?.Invoke(this, new OutputEventArgs(output)); } #endregion lock (this) _requestCancellation = requestCancellation; } while (!_requestCancellation); MonitorStopped?.Invoke(this, new EventArgs()); }
public void MonitorStart(int refreshTime) { if (IsMonitorStarted) { if (MonitorRefreshTime == refreshTime) { return; } _monitorTimer.Stop(); _monitorTimer.Interval = TimeSpan.FromMinutes(refreshTime).TotalMilliseconds; _monitorTimer.Start(); IsMonitorStarted = true; MonitorRefreshTime = refreshTime; } else { _monitorTimer.Interval = TimeSpan.FromMinutes(refreshTime).TotalMilliseconds; _monitorTimer.Start(); IsMonitorStarted = true; MonitorStarted?.Invoke(this, Name); } MonitorTimerOnElapsedAsync(_monitorTimer, null); }
public void MonitorStart(int refreshTime) { if (IsMonitorStarted) { if (MonitorRefreshTime == refreshTime) { return; } _monitorTimer.Stop(); _monitorTimer.Interval = TimeSpan.FromMinutes(refreshTime).TotalMilliseconds; _monitorTimer.Start(); IsMonitorStarted = true; MonitorRefreshTime = refreshTime; } else { _monitorTimer.Interval = TimeSpan.FromMinutes(refreshTime).TotalMilliseconds; _monitorTimer.Start(); IsMonitorStarted = true; MonitorRefreshTime = refreshTime; MonitorStarted?.Invoke(this, EventArgs.Empty); CheckForNewVersionAsync(); } }
private void OnMonitorStarted() { MonitorStarted?.Invoke(this, EventArgs.Empty); }
public void OnMonitorStarted() { MonitorStarted?.Invoke(this, new MonitorActivityEventArgs { Message = "Activity monitor started", Time = DateTime.Now }); }