Exemplo n.º 1
0
 public IAwaitable CreateAwaitable(Func<IAsyncStateMachine, Action> stateMachineHandler)
 {
     var awaiter = new YieldingAwaiter(continuation =>
     {
         var machine = AsyncUtil.GetStateMachine(continuation);
         nextAction = stateMachineHandler(machine);
     });
     return awaiter.NewAwaitable();
 }
Exemplo n.º 2
0
        public YieldingAwaitable <T> CreateYieldingAwaitable <T>(Func <IAsyncStateMachine, Action> stateMachineHandler, T value)
        {
            var awaiter = new YieldingAwaiter <T>(continuation =>
            {
                var machine = AsyncUtil.GetStateMachine(continuation);
                nextAction  = stateMachineHandler(machine);
            }, value);

            return(new YieldingAwaitable <T>(awaiter));
        }
Exemplo n.º 3
0
        public IAwaitable CreateAwaitable(Func <IAsyncStateMachine, Action> stateMachineHandler)
        {
            var awaiter = new YieldingAwaiter(continuation =>
            {
                var machine = AsyncUtil.GetStateMachine(continuation);
                nextAction  = stateMachineHandler(machine);
            });

            return(awaiter.NewAwaitable());
        }
Exemplo n.º 4
0
 public IAwaitable Retry(int times)
 {
     var awaiter = new YieldingAwaiter(continuation =>
     {
         retryCount = 0;
         retryMax = times;
         SaveState(stateMachine);
     });
     return awaiter.NewAwaitable();
 }
Exemplo n.º 5
0
        public YieldingAwaitable <T> CreateYieldingAwaitable <T>(Action <IAsyncStateMachine> stateMachineHandler, T result)
        {
            var awaiter = new YieldingAwaiter <T>(continuation =>
            {
                var machine = AsyncUtil.GetStateMachine(continuation);
                stateMachineHandler(machine);
                nextAction = continuation;
            }, result);

            return(new YieldingAwaitable <T>(awaiter));
        }
Exemplo n.º 6
0
        public IAwaitable Retry(int times)
        {
            var awaiter = new YieldingAwaiter(continuation =>
            {
                retryCount = 0;
                retryMax   = times;
                SaveState(stateMachine);
            });

            return(awaiter.NewAwaitable());
        }
Exemplo n.º 7
0
 public IAwaitable Setup()
 {
     var awaiter = new YieldingAwaiter(continuation =>
     {
         stateMachine = AsyncUtil.GetStateMachine(continuation);
         machineContinuation = continuation;
         if (savedState == null)
         {
             SaveState(stateMachine);
         }
         else
         {
             stateMachine.LoadFrom(new MemoryStream(savedState));
         }
     });
     return awaiter.NewAwaitable();
 }
Exemplo n.º 8
0
        public IAwaitable Setup()
        {
            var awaiter = new YieldingAwaiter(continuation =>
            {
                stateMachine        = AsyncUtil.GetStateMachine(continuation);
                machineContinuation = continuation;
                if (savedState == null)
                {
                    SaveState(stateMachine);
                }
                else
                {
                    stateMachine.LoadFrom(new MemoryStream(savedState));
                }
            });

            return(awaiter.NewAwaitable());
        }
Exemplo n.º 9
0
 internal YieldingAwaitable(YieldingAwaiter <T> awaiter)
 {
     this.awaiter = awaiter;
 }