Esempio n. 1
0
        private void InitTaskQueue()
        {
            Task task1 = Task.Factory.StartNew(() =>
            {
                Completed_TaskQueue          = new ConcurrentDictionary <string, T8TaskEntity>();
                string taskQueuePath         = Common.GetTaskQueueFileFullpath(TaskQueueType.Completed);
                List <T8TaskEntity> taskList = SerializableHelper <List <T8TaskEntity> > .BinaryDeserialize(taskQueuePath);
                if (taskList != null && taskList.Count > 0)
                {
                    foreach (T8TaskEntity t8Task in taskList)
                    {
                        Completed_TaskQueue.TryAdd(t8Task.GenerateTaskQueueKey, t8Task);
                    }
                }
            });

            Task task2 = Task.Factory.StartNew(() =>
            {
                Processing_TaskQueue         = new ConcurrentDictionary <string, T8TaskEntity>();
                string taskQueuePath         = Common.GetTaskQueueFileFullpath(TaskQueueType.Processing);
                List <T8TaskEntity> taskList = SerializableHelper <List <T8TaskEntity> > .BinaryDeserialize(taskQueuePath);
                if (taskList != null && taskList.Count > 0)
                {
                    foreach (T8TaskEntity t8Task in taskList)
                    {
                        Completed_TaskQueue.TryAdd(t8Task.GenerateTaskQueueKey, t8Task);
                    }
                }
            });

            Task task3 = Task.Factory.StartNew(() =>
            {
                Error_TaskQueue              = new ConcurrentDictionary <string, T8TaskEntity>();
                string taskQueuePath         = Common.GetTaskQueueFileFullpath(TaskQueueType.Error);
                List <T8TaskEntity> taskList = SerializableHelper <List <T8TaskEntity> > .BinaryDeserialize(taskQueuePath);
                if (taskList != null && taskList.Count > 0)
                {
                    foreach (T8TaskEntity t8Task in taskList)
                    {
                        Completed_TaskQueue.TryAdd(t8Task.GenerateTaskQueueKey, t8Task);
                    }
                }
            });

            Task task4 = Task.Factory.StartNew(() =>
            {
                UserManual_TaskQueue         = new ConcurrentDictionary <string, T8TaskEntity>();
                string taskQueuePath         = Common.GetTaskQueueFileFullpath(TaskQueueType.UserManual);
                List <T8TaskEntity> taskList = SerializableHelper <List <T8TaskEntity> > .BinaryDeserialize(taskQueuePath);
                if (taskList != null && taskList.Count > 0)
                {
                    foreach (T8TaskEntity t8Task in taskList)
                    {
                        Completed_TaskQueue.TryAdd(t8Task.GenerateTaskQueueKey, t8Task);
                    }
                }
            });

            Task.WaitAll(new[] { task1, task2, task3, task4 });
        }