private void TaskCompleted(SharpEncryptTaskModel task) { ActiveTasks.Remove(task); ActiveTasksGridView.Refresh(); if (!ActiveTasks.Any()) { AllTasksCompleted?.Invoke(); } }
public void TaskCompleted() { var allTasks = _allTasks; var completedTasks = Interlocked.Increment(ref _completedTasks); if (allTasks == completedTasks) { IsCompleted = true; AllTasksCompleted?.Invoke(this, _empty); } }
private void ActiveTasksForm_Load(object sender, EventArgs e) { Text = ResourceManager.GetString("ActiveTasks"); ActiveTasks.AddRange(TaskManager.Tasks); TaskManager.TaskCompleted += TaskCompleted; TaskManager.TaskManagerCompleted += TaskManagerCompleted; if (!ActiveTasks.Any() || ActiveTasks.All(x => x.InnerTask.IsCompleted)) { AllTasksCompleted?.Invoke(); } ActiveTasksGridView.AutoGenerateColumns = false; ActiveTasksGridView.DataSource = ActiveTasks; ActiveTasksGridView.Refresh(); }
private void TaskManagerCompleted(bool hasRemainingTasks) => AllTasksCompleted?.Invoke();