コード例 #1
0
 /// <summary>
 /// Initializes the job
 /// </summary>
 public Job(long idJob, Task task)
 {
     TaskId = idJob;
     _task  = task;
     // Set the status
     lock (_statusLock)
     {
         Status = Enums.JobStatus.Requested;
     }
 }
コード例 #2
0
        /// <summary>
        /// Pause the job
        /// </summary>
        public void Pause()
        {
            // Set the status
            lock (_statusLock)
            {
                Status = Enums.JobStatus.Paused;
            }

            // Reset the event handler to make the thread wait
            _pauseEvent.Reset();
        }
コード例 #3
0
        /// <summary>
        /// Resumes the job
        /// </summary>
        public void Resume()
        {
            // Set the status
            lock (_statusLock)
            {
                Status = Enums.JobStatus.Running;
            }

            // Set the event handler to make the thread resume execution within the loop
            _pauseEvent.Set();
        }
コード例 #4
0
        /// <summary>
        /// Runs the job.
        /// </summary>
        /// <param name="taskId">The task identifier.</param>
        /// <param name="facilityId">The facility identifier.</param>
        /// <param name="connectionString">The connection string.</param>
        public void RunJob(long taskId, int facilityId, string connectionString)
        {
            var selectClaimsLogic = Factory.CreateInstance <IClaimSelectorLogic>(connectionString, true);

            // Create a new task to start adjudicating claims as per the conditions in the given idJob and facilityid
            _task =
                Task.Factory.StartNew(
                    () =>
                    selectClaimsLogic.AdjudicateClaimDataThread(taskId, facilityId, GlobalConfigVariable.NoOfRecordsForAdjudicate,
                                                                connectionString, false));

            lock (_statusLock)
            {
                Status = Enums.JobStatus.Running;
            }
        }
コード例 #5
0
        /// <summary>
        /// Stop the job
        /// </summary>
        public void Stop()
        {
            // Set the status
            lock (_statusLock)
            {
                Status = Enums.JobStatus.Cancelled;
            }

            //Signal the shutdown event. Set the event handler to make the thread exit gracefully
            _shutdownEvent.Set();

            // Make sure to resume any paused threads
            _pauseEvent.Set();
            // Wait for a minute for the task to complete - OPTIONAL
            _task.Wait(60000);
        }