Example #1
0
        private void ExecuteContinously()
        {
            while (_isRunning)
            {
                bool isExecuteNeeded;
                lock (_locker)
                {
                    isExecuteNeeded = _firstNewOffer.HasValue && _dependencyFactory.DateTimeProvider.Now >= _firstNewOffer.Value.AddSeconds(_consumer.Delay);
                }
                if (isExecuteNeeded)
                {
                    _consumer.Execute();
                }

                _resetEvent.Wait(1000);
            }
        }
Example #2
0
        private void ExecuteTasks()
        {
            while (_isWorkerRunning)
            {
                _workerBarrier.Wait(1000);

                List <BaseTask> tasksToExecute;
                lock (_tasks)
                {
                    tasksToExecute = new List <BaseTask>(_tasks);
                    _tasks.Clear();
                }

                foreach (var task in tasksToExecute)
                {
                    ProcessTask(task);
                }
            }
        }