Statistiques
| Branche: | Révision:

teotestbluetooth / TestXamConnections / TestXamConnections.Android / Utils / TaskExtensions.cs @ master

Historique | Voir | Annoter | Télécharger (529 octets)

1
using System.Threading;
2
using System.Threading.Tasks;
3

    
4
namespace TestXamConnections.Droid.Utils
5
{
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
}