Exemplo n.º 1
0
        public AsyncReply <string> Stream(int count)
        {
            var   reply      = new AsyncReply <string>();
            var   msg        = new object[] { "Have you throught what if a function has multiple returns ?", "So you can return chunks of IO operation that not yet finished.", "Also, what about the progress ?", "This is an example of both.", "Use it anyway you like" };
            Timer timer      = null;
            var   msgCounter = 0;

            timer = new Timer((x) =>
            {
                reply.TriggerProgress(AsyncReply.ProgressType.Execution, count, 22);

                if (count % 2 == 0 && msgCounter < msg.Length)
                {
                    reply.TriggerChunk(msg[msgCounter++]);
                }

                count--;
                if (count <= 0)
                {
                    timer.Dispose();
                    reply.Trigger("Done");
                }
            }, null, 10, 3000);

            return(reply);
        }
        public AsyncReply <int> ChildMethod(string childName)
        {
            var rt = new AsyncReply <int>();

            _InvokeByArrayArguments(0, new object[] { childName })
            .Then(x => rt.Trigger((int)x))
            .Error(x => rt.TriggerError(x))
            .Chunk(x => rt.TriggerChunk(x));
            return(rt);
        }
Exemplo n.º 3
0
        public AsyncReply <object> ConnectionOptional(object a1, int a2, string a3)
        {
            var rt = new AsyncReply <object>();

            _InvokeByArrayArguments(4, new object[] { a1, a2, a3 })
            .Then(x => rt.Trigger((object)x))
            .Error(x => rt.TriggerError(x))
            .Chunk(x => rt.TriggerChunk(x));
            return(rt);
        }
Exemplo n.º 4
0
        public AsyncReply <object> InvokeEvents(string msg)
        {
            var rt = new AsyncReply <object>();

            _InvokeByArrayArguments(1, new object[] { msg })
            .Then(x => rt.Trigger((object)x))
            .Error(x => rt.TriggerError(x))
            .Chunk(x => rt.TriggerChunk(x));
            return(rt);
        }
Exemplo n.º 5
0
        public AsyncReply <object> Void()
        {
            var rt = new AsyncReply <object>();

            _InvokeByArrayArguments(0, new object[] {  })
            .Then(x => rt.Trigger((object)x))
            .Error(x => rt.TriggerError(x))
            .Chunk(x => rt.TriggerChunk(x));
            return(rt);
        }