Beispiel #1
0
        /// <summary>
        /// 异步执行节点任务
        /// </summary>
        /// <param name="north"></param>
        private void InvokeComputeNodeTask(BerComputeNode n)
        {
            RunNodeDelegate runNode = RunOne;

            runNode.BeginInvoke(n, ar =>
            {// 380, 120
                string response = runNode.EndInvoke(ar);
                ShowInfo(n.ToString() + "返回信息:" + response);
            }, runNode);
        }
Beispiel #2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            ShowInfo("开始工作....");
            watch.Restart();

            //统计有多少个任务
            _taskCount = 0;
            foreach (var item in ComputeNodes)
            {
                if (item.Enabled)
                {
                    _taskCount += item.TaskCount;
                }
            }

            //清零工作记录列表
            foreach (var node in ComputeNodes)
            {
                if (node.Enabled)
                {
                    if (!ComputeNodeTaskDic.ContainsKey(node))
                    {
                        ComputeNodeTaskDic.Add(node, 0);
                    }
                    else
                    {
                        ComputeNodeTaskDic[node] = 0;
                    }
                }
            }


            //首次分配任务
            for (int i = 0; i < ComputeNodes.Count; i++)
            {
                BerComputeNode n = ComputeNodes[i];
                if (n.Enabled)
                {
                    string msg = n.ToString() + "开始执行......";
                    ShowInfo(msg);

                    InvokeComputeNodeTask(n);
                }
            }
        }