Esempio n. 1
0
        public ArraysTurple A()
        {
            int[,] M1 = new int[n, n];
            int[] M2 = new int[n];

            Random rand = new Random();

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    M1[i, j] = rand.Next(n);
                }
            }
            for (int i = 0; i < M2.Length; i++)
            {
                M2[i] = rand.Next(0, 100);
            }

            var infoTask = new Info()
            {
                id = "A", time_end = "[TIME STOP]: " + DateTime.Now + ":" + DateTime.Now.Millisecond
            };

            TaskComplete?.Invoke(infoTask);
            return(new ArraysTurple {
                M1 = M1, M2 = M2
            });
        }
Esempio n. 2
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            timer.Stop();

            foreach (var task in Tasks.Values)
            {
                if (!task.IsStart || task.IsStop || task.IsComplete)
                {
                    continue;
                }

                ThunderDll.QueryTaskInfo(task.ID, task.Info);

                if (task.Info.Status == ThunderDll.DOWN_TASK_STATUS.TSC_STOPENDING)
                {
                    task.IsStop = true;
                }

                if (task.Info.Status == ThunderDll.DOWN_TASK_STATUS.TSC_COMPLETE)
                {
                    TaskComplete?.Invoke(this, task);
                    task.IsComplete = true;
                }

                TaskInfoChange?.Invoke(this, task);
            }

            if (AutoManage)
            {
                int cnt = RunTaskCount();
                if (cnt < MaxTaskCount)
                {
                    foreach (var task in Tasks.Values)
                    {
                        if (!task.IsStart)
                        {
                            task.StartTask();
                            cnt++;
                        }

                        if (cnt >= MaxTaskCount)
                        {
                            break;
                        }
                    }
                }

                DeleteCompleted();
            }

            if (!Exit)
            {
                timer.Start();
            }
        }
Esempio n. 3
0
        public void K(int resF, int resG, int resH)
        {
            //some func
            int res      = resF + resG + resH;
            var infoTask = new Info()
            {
                id = "K", time_end = "[TIME STOP]: " + DateTime.Now + ":" + DateTime.Now.Millisecond
            };

            TaskComplete?.Invoke(infoTask);
        }
Esempio n. 4
0
        public int H(int resE, int resD)
        {
            int res      = resD * resE * 3;
            var infoTask = new Info()
            {
                id = "H", time_end = "[TIME STOP]: " + DateTime.Now + ":" + DateTime.Now.Millisecond
            };

            TaskComplete?.Invoke(infoTask);
            return(res);
        }
Esempio n. 5
0
        public int E(int result)
        {
            var res      = result / 50;
            var infoTask = new Info()
            {
                id = "E", time_end = "[TIME STOP]: " + DateTime.Now + ":" + DateTime.Now.Millisecond
            };

            TaskComplete?.Invoke(infoTask);
            return(res);
        }
Esempio n. 6
0
        public int C(ArraysTurple result)
        {
            var M1  = result.M1;
            var M2  = result.M2;
            int res = 0;

            for (int i = 0; i < M2.Length; i++)
            {
                res = M2[i] - 100;
            }

            var infoTask = new Info()
            {
                id = "C", time_end = "[TIME STOP]: " + DateTime.Now + ":" + DateTime.Now.Millisecond
            };

            TaskComplete?.Invoke(infoTask);
            return(res);
        }
Esempio n. 7
0
        public int B(ArraysTurple result)
        {
            var M1  = result.M1;
            var M2  = result.M2;
            int res = 0;

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    res = M1[i, j] + res;
                }
            }

            var infoTask = new Info()
            {
                id = "B", time_end = "[TIME STOP]: " + DateTime.Now + ":" + DateTime.Now.Millisecond
            };

            TaskComplete?.Invoke(infoTask);
            return(res);
        }
        private void TryBackup(TaskInfo task)
        {
            DateTime now = DateTime.Now;

            if (existTask == null)//如果没有正在备份
            {
                //if (!Directory.Exists(task.TargetDirectory))//如果不存在目标目录
                //{
                //    try
                //    {
                //        //尝试去创建
                //        Directory.CreateDirectory(task.TargetDirectory);
                //    }
                //    catch
                //    {
                //        task.LastBackupTime = now;
                //        //  AppendLog(itemsName[i], "目标目录不存在且无法创建,将在下一个周期重试。");
                //        //  txtLogPanel.Text = log.ToString();
                //        //  lvwTasks.Items.Refresh();
                //        return;
                //    }

                //}
                //else//如果目录存在
                //{
                //如果校验失败

                task.Status = TaskInfo.Statuses.BackingUp;

                currentCore = new BackupCore(task);
                Task t = new Task(currentCore.Backup);
                existTask = t;
                t.ContinueWith(p =>
                {
                    existTask   = null;
                    task.Status = TaskInfo.Statuses.Waiting;
                    if (task.RealTime)
                    {
                        task.LastBackupTime = DateTime.MaxValue;

                        task.DisplayStatus = "正在侦测";
                    }
                    else
                    {
                        task.LastBackupTime = DateTime.Now;
                    }
                    if (needToStop)
                    {
                        timer.Stop();
                        needToStop = false;
                    }
                    App.Current?.Dispatcher.Invoke(() =>
                    {
                        if (App.Current.MainWindow as MainWindow != null && App.Current.MainWindow.Visibility == System.Windows.Visibility.Visible)
                        {
                            (App.Current.MainWindow as MainWindow).ResetButtons();
                        }
                    });
                    TaskComplete?.Invoke(this, new TaskCompleteEventArgs(task));
                });
                t.Start();

                // }
            }
            else//如果正在备份其他的东西
            {
                task.DisplayStatus = "排队中";

                LogHelper.AppendLog(task, "因已有工作中的备份任务,该任务正在排队等待");
                task.Status = TaskInfo.Statuses.InTheLine;
            }
        }