annotate Implab.Test/PromiseHelper.cs @ 10:aa33d0bb8c0c promises

implemeted new cancellable promises concept
author cin
date Sun, 03 Nov 2013 18:07:38 +0400
parents
children 6ec82bf68c8e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
1 using System;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
2 using System.Collections.Generic;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
3 using System.Linq;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
4 using System.Text;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
5 using System.Threading;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
6
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
7 namespace Implab.Test {
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
8 class PromiseHelper {
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
9 public static Promise<T> Sleep<T>(int timeout, T retVal) {
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
10 return AsyncPool.Invoke(() => {
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
11 Thread.Sleep(timeout);
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
12 return retVal;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
13 });
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
14 }
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
15 }
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
16 }