teotestbluetooth / TestXamConnections / TestXamConnections.Android / Utils / TaskExtensions.cs @ c478f8e5
Historique | Voir | Annoter | Télécharger (529 octets)
1 | 3fa496d6 | Martin Toutant | using System.Threading; |
---|---|---|---|
2 | 3c62e059 | Martin Toutant | using System.Threading.Tasks; |
3 | |||
4 | 91ef3e8c | Martin Toutant | namespace TestXamConnections.Droid.Utils |
5 | 3c62e059 | Martin Toutant | { |
6 | public static class TaskExtensions |
||
7 | { |
||
8 | public static Task WithCancellation(this Task task, CancellationToken token) |
||
9 | { |
||
10 | return task.ContinueWith(t => t.GetAwaiter().GetResult(), token); |
||
11 | } |
||
12 | |||
13 | public static Task<T> WithCancellation<T>(this Task<T> task, CancellationToken token) |
||
14 | { |
||
15 | return task.ContinueWith(t => t.GetAwaiter().GetResult(), token); |
||
16 | } |
||
17 | } |
||
18 | } |