Example #1
0
 /// <summary>
 /// Actual single-job Thread Code.
 /// </summary>
 protected override void execute()
 {
     try
     {
         while (true)
         {
             if (m_workPool.IsEmpty())
             {
                 break;
             }
             Debug.Assert(m_jobProcessor != null, "Job Processor is NULL!");
             if (m_jobProcessor == null)
             {
                 break;
             }
             BaseJob jobPtr = m_workPool.Dequeue();
             jobPtr.JobReport(JobStatus.IN_PROCESS);
             m_jobProcessor.DoJob(this, jobPtr);
             jobPtr.JobReport(JobStatus.DONE);
         }
         callCallBack();
     }
     catch (ThreadAbortException)
     {
         while (m_workPool.IsEmpty())
         {
             BaseJob jobPtr = m_workPool.Dequeue();
             jobPtr.JobReport(JobStatus.INCOMPLETE);
         }
     }
 }
Example #2
0
 /// <summary>
 /// Push in the new work to the work pool.
 /// </summary>
 /// <param name="work">the new work to put into the work pool.</param>
 public void Push(BaseJob work)
 {
     m_workPool.Enqueue(work);
     if (m_lifePolicy == ThreadLifePolicy.SUSPEND_AFTER_WORK)
     {
         Resume();
     }
 }
Example #3
0
 /// <summary>
 /// Actual infinite-looping Thread Code.
 /// </summary>
 protected override void execute()
 {
     try
     {
         while (true)
         {
             if (m_terminateEvent.WaitForEvent(0))
             {
                 return;
             }
             if (m_workPool.IsEmpty())
             {
                 if (m_lifePolicy == ThreadLifePolicy.SUSPEND_AFTER_WORK)
                 {
                     callCallBack();
                     Suspend();
                     continue;
                 }
                 callCallBack();
                 Thread.Sleep(0);
                 continue;
             }
             Debug.Assert(m_jobProcessor != null, "Job Processor is NULL!");
             if (m_jobProcessor == null)
             {
                 break;
             }
             BaseJob jobPtr = m_workPool.Dequeue();
             jobPtr.JobReport(JobStatus.IN_PROCESS);
             m_jobProcessor.DoJob(this, jobPtr);
             jobPtr.JobReport(JobStatus.DONE);
         }
     }
     catch (ThreadAbortException)
     {
         while (m_workPool.IsEmpty())
         {
             BaseJob jobPtr = m_workPool.Dequeue();
             jobPtr.JobReport(JobStatus.INCOMPLETE);
         }
     }
 }
Example #4
0
 /// <summary>
 /// Erase the given work from the work pool.
 /// </summary>
 /// <param name="work">the work to erase from the work pool</param>
 /// <returns>true if successful, otherwise false.</returns>
 public bool Erase(BaseJob work)
 {
     return(m_workPool.Erase(work));
 }
Example #5
0
 /// <summary>
 /// Process the job given, subclasses must implement this function.
 /// </summary>
 /// <param name="workerThread">The worker thread which called the DoJob.</param>
 /// <param name="data">The job given to this object.</param>
 public abstract void DoJob(BaseWorkerThread workerThread, BaseJob data);