Mercurial > pub > ImplabNet
annotate Implab.Test/PromiseHelper.cs @ 203:4d9830a9bbb8 v2
Added 'Fail' method to RunnableComponent which allows component to move from
Running to Failed state.
Added PollingComponent a timer based runnable component
More tests
Added FailPromise a thin class to wrap exceptions
Fixed error handling in SuccessPromise classes.
author | cin |
---|---|
date | Tue, 18 Oct 2016 17:49:54 +0300 |
parents | eb793fbbe4ea |
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 } |