Mercurial > pub > ImplabNet
annotate Implab.Test/PromiseHelper.cs @ 220:42814145d472 v2
.csproj changes
author | cin |
---|---|
date | Tue, 20 Jun 2017 19:45:52 +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 } |