annotate Implab.Test/PromiseHelper.cs @ 187:dd4a3590f9c6
ref20160224
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler
Any unhandled OperationCanceledException will cause the promise cancelation
author |
cin |
date |
Tue, 19 Apr 2016 17:35:20 +0300 |
parents |
eb793fbbe4ea |
children |
4d9830a9bbb8 |
rev |
line source |
11
|
1 using Implab.Parallels;
|
10
|
2 using System.Threading;
|
|
3
|
|
4 namespace Implab.Test {
|
77
|
5 static class PromiseHelper {
|
73
|
6 public static IPromise<T> Sleep<T>(int timeout, T retVal) {
|
149
|
7 return AsyncPool.Invoke((ct) => {
|
|
8 ct.CancellationRequested(ct.CancelOperation);
|
10
|
9 Thread.Sleep(timeout);
|
|
10 return retVal;
|
|
11 });
|
|
12 }
|
|
13 }
|
|
14 }
|