Esempio n. 1
0
        public ResultFuture <TResult> Enqueue <T, TResult>(T data, Func <T, TResult> work)
        {
            var future = new ResultFuture <TResult>();

            DoWork(data, work, future);
            return(future);
        }
Esempio n. 2
0
        public ResultFuture <T> Enqueue <T>(Func <T> work)
        {
            var future = new ResultFuture <T>();

            DoWork(work, future);
            return(future);
        }
        public ResultFuture <TResult> Enqueue <T, TResult>(T data, Func <T, TResult> work)
        {
            var future = new ResultFuture <TResult>();

            ThreadPool.QueueUserWorkItem(o => DoWork((T)o, work, future), data);
            return(future);
        }
        public ResultFuture <T> Enqueue <T>(Func <T> work)
        {
            var future = new ResultFuture <T>();

            ThreadPool.QueueUserWorkItem(o => DoWork(work, future));
            return(future);
        }
Esempio n. 5
0
 private static void DoWork <T>(Func <T> work, ResultFuture <T> future)
 {
     try {
         future.Set(work());
     } catch (Exception e) {
         future.Failed(e);
     }
 }
Esempio n. 6
0
 private static void DoWork <T, TResult>(T data, Func <T, TResult> work, ResultFuture <TResult> future)
 {
     try {
         future.Set(work(data));
     } catch (Exception e) {
         future.Failed(e);
     }
 }