annotate Implab.Test/PromiseHelper.cs @ 231:3eaa9372c754 v2

Added SerializationHelpers.SerializeToFile method
author cin
date Thu, 21 Sep 2017 01:06:32 +0300
parents 4d9830a9bbb8
children d82909310094
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
6ec82bf68c8e refactoring
cin
parents: 10
diff changeset
1 using Implab.Parallels;
10
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
2 using System.Threading;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
3
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
4 namespace Implab.Test {
77
91362ffbecf8 ported tests to mono
cin
parents: 73
diff changeset
5 static class PromiseHelper {
73
3b8393be3441 fixed tests
cin
parents: 11
diff changeset
6 public static IPromise<T> Sleep<T>(int timeout, T retVal) {
149
eb793fbbe4ea fixed promises cancellation
cin
parents: 77
diff changeset
7 return AsyncPool.Invoke((ct) => {
eb793fbbe4ea fixed promises cancellation
cin
parents: 77
diff changeset
8 ct.CancellationRequested(ct.CancelOperation);
10
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
9 Thread.Sleep(timeout);
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
10 return retVal;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
11 });
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
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
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
21 }
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
22 }