Esempio n. 1
0
            private void _doWork()
            {
                while (!_requestStop)
                {
                    WorkerTask task = _pool.DequeueTask();
                    if (task != null)
                    {
                        // Process the task
                        task.AssignedWorkerThread = this;
                        try {
                            _isProcessingTask = true;
                            _taskStartTime    = DateTime.UtcNow;

                            task.Process();

                            _isProcessingTask = false;
                            _taskEndTime      = DateTime.UtcNow;
                        } catch (Exception e) {
                            _isProcessingTask = false;
                            _taskEndTime      = DateTime.UtcNow;
                        }
                    }
                    else
                    {
                        // Wait a bit
                        Thread.Sleep(10);
                    }
                }
                // Finish
                _pool.RemoveWorker(this);
            }