Mercurial > pub > ImplabNet
diff Implab/Safe.cs @ 259:7d52dc684bbd v3
PollingComponent: implemented correct stopping
author | cin |
---|---|
date | Fri, 13 Apr 2018 03:57:39 +0300 |
parents | 7c7e9ad6fe4a |
children | 9d1cca834b05 |
line wrap: on
line diff
--- a/Implab/Safe.cs Fri Apr 13 00:44:57 2018 +0300 +++ b/Implab/Safe.cs Fri Apr 13 03:57:39 2018 +0300 @@ -7,6 +7,7 @@ using System.Collections; using System.Runtime.CompilerServices; using System.Threading.Tasks; +using System.Threading; #if NET_4_5 using System.Threading.Tasks; @@ -151,6 +152,21 @@ public static void NoWait<T>(Task<T> promise) { } + public static void Noop() { + } + + public static void Noop(CancellationToken ct) { + ct.ThrowIfCancellationRequested(); + } + + public static Task CreateTask() { + return new Task(Noop); + } + + public static Task CreateTask(CancellationToken ct) { + return new Task(Noop, ct); + } + [DebuggerStepThrough] public static IPromise<T> Run<T>(Func<IPromise<T>> action) { ArgumentNotNull(action, "action"); @@ -162,10 +178,5 @@ } } -#if NET_4_5 - public static void NoWait(Task t) { - } -#endif - } }