Mercurial > pub > ImplabNet
annotate Implab.Test/PromiseHelper.cs @ 245:b904e0a3ba72 v3
working on promises
author | cin |
---|---|
date | Fri, 26 Jan 2018 04:13:34 +0300 |
parents | 4d9830a9bbb8 |
children | d82909310094 |
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 } | |
203
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
149
diff
changeset
|
13 |
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
149
diff
changeset
|
14 public static IPromise Sleep(int timeout) { |
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
149
diff
changeset
|
15 return AsyncPool.Invoke((ct) => { |
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
149
diff
changeset
|
16 ct.CancellationRequested(ct.CancelOperation); |
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
149
diff
changeset
|
17 Thread.Sleep(timeout); |
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
149
diff
changeset
|
18 return 0; |
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
149
diff
changeset
|
19 }); |
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
149
diff
changeset
|
20 } |
10 | 21 } |
22 } |