public void CanBindFutureToOtherFuture() { var a = new Future <object>(); var b = new Future <object>(); b.Bind(a); a.Complete(5); Assert.AreEqual(5, b.Result); }
public void BindToProperty() { var tc = new TestClass(); var ts = new TestStruct(); var f = new Future <int>(); f.Bind(() => tc.Property); try { f.Bind(() => ts.Property); Assert.Fail("Did not throw InvalidOperationException"); } catch (InvalidOperationException) { } f.Complete(5); Assert.AreEqual(5, tc.Property); Assert.AreNotEqual(5, ts.Property); }
public StoreResult( IEnumerator <object> task, Expression <Func <T> > target, TaskExecutionPolicy executionPolicy = TaskExecutionPolicy.RunWhileFutureLives ) { _Task = task; _Thunk = new SchedulableGeneratorThunk(_Task); _ExecutionPolicy = executionPolicy; _Future = Future.New <T>(); _Future.Bind(target); _Future.RegisterOnComplete(Completed); }