Exemplo n.º 1
0
        /// <summary>
        /// 调用函数
        /// </summary>
        /// <param name="input">可选个数的输入参数</param>
        /// <returns></returns>
        public object DoAction(params object[] input)
        {
            EventNeedRun whatTodo = CombineActionAndManuset;
            //通过BeginInvoke方法,在线程池上异步的执行方法。
            IAsyncResult r = whatTodo.BeginInvoke(input, MyAsyncCallback, null);

            //设置阻塞,如果上述的BeginInvoke方法在timeout之前运行完毕,则manu会收到信号。此时isGetSignal为true。
            //如果timeout时间内,还未收到信号,即异步方法还未运行完毕,则isGetSignal为false。
            this.IsGetSignal = this._manu.WaitOne(this.Timeout);

            return(this.IsGetSignal ? whatTodo.EndInvoke(r) : null);
        }
Exemplo n.º 2
0
        ///
        /// 调用函数
        /// 可选个数的输入参数
        ///
        public object doAction(params object[] input)
        {
            EventNeedRun WhatTodo = CombineActionAndManuset;
            //通过BeginInvoke方法,在线程池上异步的执行方法。
            var r = WhatTodo.BeginInvoke(input, MyAsyncCallback, null);

            //设置阻塞,如果上述的BeginInvoke方法在timeout之前运行完毕,则manu会收到信号。此时isGetSignal为true。
            //如果timeout时间内,还未收到信号,即异步方法还未运行完毕,则isGetSignal为false。
            isGetSignal = manu.WaitOne(timeout);
            if (isGetSignal == true)
            {
                return(WhatTodo.EndInvoke(r));
            }
            else
            {
                return(null);
            }
        }