コード例 #1
0
        public void Reason_get_should_return_the_reason_why_a_promise_has_been_rejected_if_state_is_rejected()
        {
            ISailor  s       = A.Sailor();
            IPromise promise = s.Promise;

            Exception exc = new Exception("Exception");

            s.Reject(exc);

            //a rejected promise reason should return the exception passed to the Sailor.Reject method
            Assert.Equal(exc, s.Promise.Reason);
        }
コード例 #2
0
        public IPromise Run()
        {
            ISailor sailor = A.Sailor();

            new Thread(
                delegate()
            {
                try {
                    while (true)
                    {
                        //My long execution...
                        Thread.Sleep(1000);
                        sailor.Notify("Something happened");
                    }
                } catch (Exception exception) {
                    sailor.Reject(exception);
                } finally {
                    sailor.Finally();
                }
            }
                ).Start();

            return(sailor.Promise);
        }