Ejemplo n.º 1
0
 public void Log(object log)
 {
     Logs.Enqueue($"[{DateTime.Now}] {log}");
     if (!(LogWorker?.IsBusy ?? true))
     {
         LogWorker?.RunWorkerAsync();
     }
 }
Ejemplo n.º 2
0
            public void Start(string fileName)
            {
                #region Early Termination Checks
                if (string.IsNullOrWhiteSpace(fileName))
                {
                    return;
                }

                FileInfo temp;

                try
                {
                    temp = new FileInfo(fileName);
                }
                catch (Exception)
                {
                    MessageBox.Show(messageBoxText: "File Name is Not Valid", caption: "Malformed File Name", button: MessageBoxButton.OK, icon: MessageBoxImage.Error);
                    return;
                }

                if (!temp.Exists)
                {
                    MessageBox.Show(messageBoxText: "Provided File Name Could Not Be Located", caption: "File Not Found", button: MessageBoxButton.OK, icon: MessageBoxImage.Error);
                    return;
                }
                #endregion

                worker = new LogWorker(fileName);

                worker.MonitorStopped += delegate
                {
                    StopRunning?.Invoke(this, new EventArgs());
                };

                worker.OutputUpdate += (obj, args) =>
                {
                    Application.Current.Dispatcher.Invoke(new Action(() => output.Text = args.Output));
                };

                worker.RunWorkerAsync();

                StartRunning?.Invoke(this, new EventArgs());
            }