comparison 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
comparison
equal deleted inserted replaced
258:d0876436d95d 259:7d52dc684bbd
5 using System.Text.RegularExpressions; 5 using System.Text.RegularExpressions;
6 using System.Diagnostics; 6 using System.Diagnostics;
7 using System.Collections; 7 using System.Collections;
8 using System.Runtime.CompilerServices; 8 using System.Runtime.CompilerServices;
9 using System.Threading.Tasks; 9 using System.Threading.Tasks;
10 using System.Threading;
10 11
11 #if NET_4_5 12 #if NET_4_5
12 using System.Threading.Tasks; 13 using System.Threading.Tasks;
13 #endif 14 #endif
14 15
149 } 150 }
150 151
151 public static void NoWait<T>(Task<T> promise) { 152 public static void NoWait<T>(Task<T> promise) {
152 } 153 }
153 154
155 public static void Noop() {
156 }
157
158 public static void Noop(CancellationToken ct) {
159 ct.ThrowIfCancellationRequested();
160 }
161
162 public static Task CreateTask() {
163 return new Task(Noop);
164 }
165
166 public static Task CreateTask(CancellationToken ct) {
167 return new Task(Noop, ct);
168 }
169
154 [DebuggerStepThrough] 170 [DebuggerStepThrough]
155 public static IPromise<T> Run<T>(Func<IPromise<T>> action) { 171 public static IPromise<T> Run<T>(Func<IPromise<T>> action) {
156 ArgumentNotNull(action, "action"); 172 ArgumentNotNull(action, "action");
157 173
158 try { 174 try {
160 } catch (Exception err) { 176 } catch (Exception err) {
161 return Promise.Reject<T>(err); 177 return Promise.Reject<T>(err);
162 } 178 }
163 } 179 }
164 180
165 #if NET_4_5
166 public static void NoWait(Task t) {
167 }
168 #endif
169
170 } 181 }
171 } 182 }