Пример #1
0
 private void CompletedTask(ThreadTask task)
 {
     CompletedTasks.Add(task);
     ActiveTasks.Remove(task);
     if (task.IsError)
     {
         OnErrorTask?.Invoke(this, new ThreadManagerScheduledTaskEventArgs(task));
     }
     else
     {
         OnCompletedTask?.Invoke(this, new ThreadManagerScheduledTaskEventArgs(task));
     }
 }
Пример #2
0
 public void Run()
 {
     StartedOn = DateTime.Now;
     OnStartedTask?.Invoke(this, new ThreadTaskEventArgs());
     try
     {
         TaskToComplete.Invoke();
     }
     catch (Exception e)
     {
         IsError   = true;
         Exception = e;
         OnErrorTask?.Invoke(this, new ThreadTaskEventArgs(e));
     }
     CompletedOn = DateTime.Now;
     OnCompletedTask?.Invoke(this, new ThreadTaskEventArgs());
 }