Exemplo n.º 1
0
        private void EnqueueJob(SortingJob job)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            try
            {
                // Execute the sorting logic
                job.Sort();
                job.Status = SortingJobStatus.Completed;
            }
            catch (InvalidOperationException e)
            {
                this.logger.LogError($"Error while executing sorting job '{job.Id}': {e.Message}");
                job.Status = SortingJobStatus.Error;

                throw e;
            }
            finally
            {
                // Tracked time: until sorting is complete
                stopwatch.Stop();

                // Update the job
                job.Duration = stopwatch.ElapsedMilliseconds;
            }
        }