public void UpdateTaskCollections()
        {
            if (LoadedProject.Tasks != null)
            {
                ToDoTasks.Clear();
                InProgressTasks.Clear();
                CompletedTasks.Clear();

                foreach (ProjectTask task in LoadedProject.Tasks)
                {
                    switch (task.Stage)
                    {
                    case Stage.ToDo:
                        ToDoTasks.Add(task);
                        break;

                    case Stage.InProgress:
                        InProgressTasks.Add(task);
                        break;

                    case Stage.Completed:
                        CompletedTasks.Add(task);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
 private void TaskCompleted()
 {
     CompletedTasks.Add(SelectedTask);
     DeleteTask();
     IsCompletedTasksListOpen = true;
     Messenger.Default.Send(new NotificationMessage("OpenMainWindow"));
     _timer.Stop();
     WorkingTime  = null;
     WorkingStage = null;
 }
Exemple #3
0
 private void CompletedTask(ThreadTask task)
 {
     CompletedTasks.Add(task);
     ActiveTasks.Remove(task);
     if (task.IsError)
     {
         OnErrorTask?.Invoke(this, new ThreadManagerScheduledTaskEventArgs(task));
     }
     else
     {
         OnCompletedTask?.Invoke(this, new ThreadManagerScheduledTaskEventArgs(task));
     }
 }
        void UpdateCompletedTasks()
        {
            var collection = Database.GetCollection <SmartEarthTask>(Core.COMPLETED_TASK_DATABASE_DOCUMENT);
            var tasks      = collection.FindAll();

            if (tasks == null)
            {
                return;
            }
            CompletedTasks.Clear();
            CompletedTasks.AddRange(tasks);
            RaisePropertyChanged("CompletedTasks");
        }
Exemple #5
0
 // Move task from _userTasks to _completedTasks
 private void MoveTaskToCompleted(UserTask task)
 {
     task.TaskStatus = TaskStatus.Completed.ToString();
     UserTasks.Remove(task);
     CompletedTasks.Insert(0, task);
 }
Exemple #6
0
        private void ThreadBody(object obj)
        {
            while (!this._token.IsCancellationRequested)
            {
                foreach (var t in Tasks.Where(x => x.Retries > 0))
                {
                    if (t.RedPercent == 0)
                    {
                        t.Retries = 0;
                    }
                }

                var e = ToWork.ToList();
                if (e.Any())
                {
                    if (DnConf.Parallels == 1)
                    {
                        e.First().Start();
                    }
                    else
                    {
                        e = e.Take(Math.Min(DnConf.Parallels, e.Count)).ToList();
                        var tl = new List <Task>();
                        foreach (var x in e)
                        {
                            var t = Task.Factory.StartNew(x.Start);
                            tl.Add(t);
                        }
                        Task.WaitAll(tl.ToArray());
                    }
                }

                foreach (var task in CompletedTasks.Where(x => x.Delivered == false))
                {
                    task.Complete();
                    task.Delivered = true;
                }

                if (Tasks.Count() == Tasks.Count(x => x.Delivered))
                {
                    return;
                }


                //this._signalEvent.Reset();

                //DnTask[] tasksSnapshot;
                //lock (this._locker)
                //{
                //    tasksSnapshot = this.Tasks.ToArray();
                //    if (tasksSnapshot.Length > 0 )
                //        tasksSnapshot[0].Begin();
                //}

                //var res = WaitHandle.WaitAny(new[] {this._token.WaitHandle, this._signalEvent});
                //switch (res)
                //{
                //    case -1:
                //        break;
                //    case 0:
                //        break;
                //    case 1:
                //        break;
                //}

                Thread.Sleep(DnConf.Delay);
            }
            Console.WriteLine("DownloadService.ThreadBody exit");
        }