public void TestCoComplete() { var obj = new GameObject(); obj.name = "Generated by unit test"; var o = obj.AddComponent <UnitTestObject>(); var f = AsyncFactory.Start <string>(() => { return("ok"); }); o.Future = f; }
public void TestAsyncError() { var e = new Exception("Error"); var f = AsyncFactory.Start <string>(() => { Thread.Sleep(TimeSpan.FromSeconds(1)); throw e; }); // not finished yet. Assert.False(f.Done); f.Wait(); Assert.Equals(e, f.Error); }
public void TestAsyncSuccess() { var f = AsyncFactory.Start <string>(() => { Thread.Sleep(TimeSpan.FromSeconds(1)); return("ok"); }); // not finished yet. Assert.False(f.Done); string v = f.Get(); Assert.Equal("ok", v); }
// Use this for initialization void Start() { var f = AsyncFactory.Start <long>(() => { return(CalcFibonacci(40)); }); StartCoroutine(f.CoComplete(r => { message = "Answer = " + r.Result; })); var f2 = AsyncFactory.Start <string>(() => { return(HeavyMethod()); }); StartCoroutine(f2.CoComplete(r => { message2 = r.Result; })); }