then() public méthode

public then ( OnNext succ ) : RpcPromise
succ OnNext
Résultat RpcPromise
Exemple #1
0
 void async_call()
 {
     RpcPromise p = new RpcPromise();
     p.then(_ => {
         prx.echo_async("this is a sync text",
             delegate(string result, RpcAsyncContext ctx) {
                 Console.WriteLine("echo() result:" + result);
                 ctx.promise.data = result;
                 ctx.onNext();
                 //ctx.again();
             }, _.promise);
     }).then(_ => {
         prx.timeout_async(1, delegate(RpcAsyncContext ctx) {
             Console.WriteLine("timeout completed!");
             ctx.onNext();
         },_.promise);
     });
     RpcPromise pe = p.error(_ => {
         Console.WriteLine("async call error:"+ _.exception.ToString());
         _.onNext();
     });
     p.final(_ => {
         Console.WriteLine(" commands be executed completed!");
     });
     p.end();
 }
Exemple #2
0
        /**
         *  at here  , new promise be created as Error processing fork.
         *  you can promise.wait util the error-routine return.
         */
        public RpcPromise error(OnNext error)
        {
            RpcPromise promise = new RpcPromise();

            if (true)
            {
                OnNext succ = null;

                if (_sucesslist.Count != 0)
                {
                    succ = _sucesslist[_sucesslist.Count - 1]; // select last OnNext
                }

                KeyValuePair <RpcPromise, OnNext> kv = new KeyValuePair <RpcPromise, OnNext>(promise, succ);
                _errorlist.Add(kv);
                promise._nextPromise = this;
                promise.then(error);
            }
            return(promise);
        }
Exemple #3
0
        void test_promise()
        {
            RpcPromise p = new RpcPromise();
            p.then(delegate(RpcAsyncContext ctx) {
                ctx.promise.data = "abc";
                Console.WriteLine("step 1.1");
                ctx.promise.onNext(ctx);
            }).then(delegate(RpcAsyncContext ctx) {
                Console.WriteLine("step 1.2");
                Console.WriteLine(ctx.promise.data);
                //ctx.promise.onNext(ctx);
                ctx.promise.onError(ctx);
            });
            RpcPromise p2 = p.error(delegate(RpcAsyncContext ctx) {
                //p.onNext(ctx,ctx.promise);
                Console.WriteLine("step 2.1");
                ctx.promise.onError(ctx);
            });
            RpcPromise p3 = p2.error(delegate(RpcAsyncContext ctx) {
                Console.WriteLine("step 3.1");
                ctx.promise.onNext(ctx);
            });
            p3.then(delegate(RpcAsyncContext ctx) {
                Console.WriteLine("step 2.2");
                ctx.promise.onNext(ctx);
            });

            p.then(delegate(RpcAsyncContext ctx) {
                Console.WriteLine("step 1.3");
                ctx.promise.onNext(ctx);
            }).final(delegate(RpcAsyncContext ctx) {
                Console.WriteLine("final.");
                Console.WriteLine(ctx.promise.data);
                Console.ReadKey(true);
            }).end();
        }
Exemple #4
0
        /**
         *  at here  , new promise be created as Error processing fork.
         *  you can promise.wait util the error-routine return.
         */
        public RpcPromise error(OnNext error )
        {
            RpcPromise promise = new RpcPromise();
            if(true) {
                OnNext succ = null;

                if (_sucesslist.Count != 0) {
                    succ = _sucesslist[_sucesslist.Count - 1]; // select last OnNext
                }

                KeyValuePair<RpcPromise,OnNext> kv = new KeyValuePair<RpcPromise, OnNext>(promise,succ);
                _errorlist.Add( kv );
                promise._nextPromise = this;
                promise.then(error);
            }
            return promise;
        }