view Implab.Test/PromiseHelper.cs @ 229:5f7a3e1d32b9 v2

JsonXmlReader performance tuning JsonScanner now operates strings and doesn't parses number and literals. Added SerializationHelpers to common serialize/deserialize operations
author cin
date Tue, 12 Sep 2017 19:07:42 +0300
parents 4d9830a9bbb8
children d82909310094
line wrap: on
line source

using Implab.Parallels;
using System.Threading;

namespace Implab.Test {
    static class PromiseHelper {
        public static IPromise<T> Sleep<T>(int timeout, T retVal) {
            return AsyncPool.Invoke((ct) => {
                ct.CancellationRequested(ct.CancelOperation);
                Thread.Sleep(timeout);
                return retVal;
            });
        }

        public static IPromise Sleep(int timeout) {
            return AsyncPool.Invoke((ct) => {
                ct.CancellationRequested(ct.CancelOperation);
                Thread.Sleep(timeout);
                return 0;
            });
        }
    }
}