Mercurial > pub > ImplabNet
annotate Implab.Test/PromiseHelper.cs @ 208:7d07503621fe v2
RunnableComponent.Dispose(bool,Exception) changed to standart Dispose(bool)
IRunnable is now disposable
Code cleanups, suppressed some CodeAnalysis warnings
author | cin |
---|---|
date | Sun, 13 Nov 2016 18:28:17 +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 } |