Example #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (this.btnStart.Text == "启动")
            {
                if (MessageBox.Show("确定要启动任务吗?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    TaskController controller = new TaskController();
                    foreach (TaskElement task in sec.Tasks)
                    {
                        TaskMonitor monitor = new TaskMonitor(task);
                        controller.Start(monitor);
                    }

                    this.btnStart.Image = TaskCenter.Properties.Resources.ServiceStop;
                    this.btnStart.Text = "停止";

                    foreach (DataRow item in table.Rows)
                    {
                        item["任务状态"] = "正在执行...";
                    }
                    this.dgvTaskView.AutoResizeColumns();
                }
            }
            else
            {
                if (MessageBox.Show("确定要停止任务吗?(注:停止任务会关闭程序.)", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    this.Close();
                }
            }
        }
Example #2
0
 public void Start(TaskMonitor monitor)
 {
     this._taskDic.Add(monitor.Name, monitor);
     monitor.Start();            
 }