|
1 | 1 | using System; |
| 2 | +using System.Collections.Generic; |
2 | 3 | using System.Linq; |
3 | 4 | using System.Threading; |
4 | 5 | using System.Threading.Tasks; |
@@ -30,24 +31,26 @@ internal static async Task PollUntil(Func<bool> condition, CancellationToken ct |
30 | 31 | } |
31 | 32 | } |
32 | 33 |
|
33 | | - internal static bool WaitAll(Task[] tasks, TimeSpan timeout) |
| 34 | + internal static bool WaitAll(IEnumerable<Task> tasks, TimeSpan timeout) |
34 | 35 | { |
35 | | - return PollUntil(() => tasks.All(t => t.IsCompleted), timeout).Status == TaskStatus.RanToCompletion; |
| 36 | + PollUntil(() => tasks.All(t => t.IsCompleted), timeout).Wait(); |
| 37 | + return tasks.All(t => t.Status == TaskStatus.RanToCompletion); |
36 | 38 | } |
37 | 39 |
|
38 | | - internal static bool WaitAll(Task[] tasks) |
| 40 | + internal static void WaitAll(IEnumerable<Task> tasks) |
39 | 41 | { |
40 | | - return WaitAll(tasks, TimeSpan.MaxValue); |
| 42 | + PollUntil(() => tasks.All(t => t.IsCompleted), Timeout.InfiniteTimeSpan).Wait(); |
41 | 43 | } |
42 | 44 |
|
43 | 45 | internal static bool Wait(Task task, TimeSpan timeout) |
44 | 46 | { |
45 | | - return PollUntil(() => task.IsCompleted, timeout).Status == TaskStatus.RanToCompletion; |
| 47 | + PollUntil(() => task.IsCompleted, timeout).Wait(); |
| 48 | + return task.Status == TaskStatus.RanToCompletion; |
46 | 49 | } |
47 | 50 |
|
48 | | - internal static bool Wait(Task task) |
| 51 | + internal static void Wait(Task task) |
49 | 52 | { |
50 | | - return Wait(task, TimeSpan.MaxValue); |
| 53 | + PollUntil(() => task.IsCompleted, Timeout.InfiniteTimeSpan).Wait(); |
51 | 54 | } |
52 | 55 | } |
53 | 56 | } |
0 commit comments