teotestbluetooth / TestTeoBluetooth / TestTeoBluetooth.Android / Utils / TaskExtensions.cs @ 91ef3e8c
Historique | Voir | Annoter | Télécharger (741 octets)
1 | 3c62e059 | Martin Toutant | using Android.App; |
---|---|---|---|
2 | using Android.Content; |
||
3 | using Android.OS; |
||
4 | using Android.Runtime; |
||
5 | using Android.Views; |
||
6 | using Android.Widget; |
||
7 | using System; |
||
8 | using System.Collections.Generic; |
||
9 | using System.Linq; |
||
10 | using System.Text; |
||
11 | using System.Threading; |
||
12 | using System.Threading.Tasks; |
||
13 | |||
14 | 91ef3e8c | Martin Toutant | namespace TestXamConnections.Droid.Utils |
15 | 3c62e059 | Martin Toutant | { |
16 | public static class TaskExtensions |
||
17 | { |
||
18 | public static Task WithCancellation(this Task task, CancellationToken token) |
||
19 | { |
||
20 | return task.ContinueWith(t => t.GetAwaiter().GetResult(), token); |
||
21 | } |
||
22 | |||
23 | public static Task<T> WithCancellation<T>(this Task<T> task, CancellationToken token) |
||
24 | { |
||
25 | return task.ContinueWith(t => t.GetAwaiter().GetResult(), token); |
||
26 | } |
||
27 | } |
||
28 | } |