解决方案 »

  1.   

    int index;
            string[] args;
            public void MendthCall(string[] arg, int index)
            {
                this.index = index;
                this.args = arg;
                Thread t = new Thread(exc);
                t.Start();
            }
            public void exc()
            {
                List<string> list = GetSeverConfig();
                RemotingServerConn conn = new RemotingServerConn();
                ExecuteCOM ec = new ExecuteCOM();
                string str = "";
                for (int i = 0; i < list.Count; i++)
                {
                    ec = conn.ServerConn(list[i]);
                    str = IsLeisureServer(ec);            }
                if (str != "")
                {
                    ExecuteMenthod method = aa;
                    method(ec, str);
                }
                else
                {            }
            }
            delegate void ExecuteMenthod(ExecuteCOM s1, string s2);
            public void aa(ExecuteCOM ec, string str)
            {
                _ICOMcallback.OnExecuteComplete_Event += new ExecuteComplete_Event(ExecuteComplete_EventMethod);
                //添加回掉实例
                ec.AddOnlineCallBack(_ICOMcallback);
                //判断传递来的数组是否存在句柄
                if (index != -1)
                {
                    //把获取到的任务句柄赋给这个数组
                    args[index] = str;
                    object obj = new object();
                    //锁定修改
                    lock (obj)
                    {
                        ec.UpdateXML(str, "忙碌");//修改当前句柄为忙碌状态
                    }
                }
                //执行
                ec.ExecuteAsyncPreAndCal(args);
            }我给改成这样了,每次来一个任务就新建一个线程?