public void StartTasksExecutionTest()
        {
            bool succ=true;
            var tasks = TaskHelper.GetTasks();
            TaskManager taskManager= new TaskManager(tasks);
            taskManager.StartTasksExecution();
            Thread.Sleep(new TimeSpan(0, 0, 0, 70));
            foreach (var task in tasks)
            {
                if (!task.Success && task.Type!=Task.TaskType.Delayed)
                    succ = false;
            }

            Assert.IsTrue(succ);
        }
        public void RunServiceManager()
        {
            logger.Debug("ServiceManager Started");
            while (!_shouldstop)
            {
                lock (this)
                {
                    if (RecognizeLocation())
                    {
                        logger.Info("RecognizeLocation gave me a new location");
                        if (_taskManager != null)
                            _taskManager.RequestStop();
                        _statisticManager = new StatisticManager(_repositoryFactory, _current);
                        _taskManager = new TaskManager(_current.Tasks);
                        _taskManager.StartTasksExecution();
                    }
                    if (_statisticManager != null) _statisticManager.UpdateStatistic();

                }
                Thread.Sleep(10000);
            }

            if (_taskManager!=null && _statisticManager!=null)
            {
                lock (this)
                {
                    _statisticManager.UpdateStatistic();
                    _taskManager.RequestStop();
                }
            }
        }