Mercurial > pub > ImplabNet
comparison Implab.Test/PromiseHelper.cs @ 149:eb793fbbe4ea v2
fixed promises cancellation
author | cin |
---|---|
date | Wed, 06 May 2015 17:11:27 +0300 |
parents | 91362ffbecf8 |
children | 4d9830a9bbb8 |
comparison
equal
deleted
inserted
replaced
148:e6d4b41f0101 | 149:eb793fbbe4ea |
---|---|
2 using System.Threading; | 2 using System.Threading; |
3 | 3 |
4 namespace Implab.Test { | 4 namespace Implab.Test { |
5 static class PromiseHelper { | 5 static class PromiseHelper { |
6 public static IPromise<T> Sleep<T>(int timeout, T retVal) { | 6 public static IPromise<T> Sleep<T>(int timeout, T retVal) { |
7 return AsyncPool.Invoke(() => { | 7 return AsyncPool.Invoke((ct) => { |
8 ct.CancellationRequested(ct.CancelOperation); | |
8 Thread.Sleep(timeout); | 9 Thread.Sleep(timeout); |
9 return retVal; | 10 return retVal; |
10 }); | 11 }); |
11 } | 12 } |
12 } | 13 } |