static void Main(string[] args) { var promise = new Deferred <string, string>(MyMethod, "my promise").Promise().Done(SuccessCallback).Fail(FailCallback).Always(AlwaysCallback); var promise2 = new Deferred <string, string>(MyMethod2, "my promise").Promise().Done(SuccessCallback).Always(AlwaysCallback).Fail(FailCallback); Console.WriteLine("waiting a second ..."); Thread.Sleep(1000); promise2.Always((result) => { Console.WriteLine("deferred always"); }); Console.ReadLine(); }
public void AlwaysCallbackTest() { CallCounter counter = new CallCounter(); Deferred<None> d = new Deferred<None>(); d.Always(p => counter.Always++ ); d.Resolve(); d.Reject(); Assert.AreEqual(2, counter.Always); }