PromiseHelper.cs
22 lines
| 663 B
| text/x-csharp
|
CSharpLexer
/ Implab.Test / PromiseHelper.cs
|
|
r11 | using Implab.Parallels; | ||
|
|
r10 | using System.Threading; | ||
| namespace Implab.Test { | ||||
|
|
r77 | static class PromiseHelper { | ||
|
|
r73 | public static IPromise<T> Sleep<T>(int timeout, T retVal) { | ||
|
|
r149 | return AsyncPool.Invoke((ct) => { | ||
| ct.CancellationRequested(ct.CancelOperation); | ||||
|
|
r10 | Thread.Sleep(timeout); | ||
| return retVal; | ||||
| }); | ||||
| } | ||||
|
|
r203 | |||
| public static IPromise Sleep(int timeout) { | ||||
| return AsyncPool.Invoke((ct) => { | ||||
| ct.CancellationRequested(ct.CancelOperation); | ||||
| Thread.Sleep(timeout); | ||||
| return 0; | ||||
| }); | ||||
| } | ||||
|
|
r10 | } | ||
| } | ||||
