/// <summary> /// Construct a new future. This constructor immediately spawns a new thread /// to compute the value of this future. If any exceptions are thrown, they /// are caught and thrown again when the result is retreived. /// </summary> /// <param name="del">the delegate that computes the value of this future</param> public Future(FutureDelegate <T> del) { _computer = del; _hasValue = new Semaphore(0, 1); // locked semaphore _exception = null; ThreadPool.QueueUserWorkItem(new WaitCallback(run)); }
public Future(FutureDelegate <T> @delegate) { _delegate = @delegate; _result = @delegate.BeginInvoke(null, null); }