private async Task AddToManagedTasks(Task taskToAdd) { Tasks.Add(taskToAdd); ProgressListener?.SetCount(GetCompletedTasksCount(), GetTotalTasksCount()); try { await taskToAdd; } finally { // After the task is done update the progress listener again: ProgressListener?.SetCount(GetCompletedTasksCount(), GetTotalTasksCount()); } }