/*-------------------------------------------------------------------------
//                           UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.

THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.

UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ProgramLib
{
   /// <summary>
	/// Abstract base class for all threads
	/// </summary>
   internal abstract class BasicThread
   {
      protected Thread _thread;

      /// <summary>
		/// Spawn thread and start it
		/// </summary>
		/// <param name=""></param>
		/// <returns></returns>
      public void Start() 
      {
         _thread = new Thread(new ThreadStart(DoWork));
         _thread.Start();
      }

      /// <summary>
		/// Method that executes on the thread.
      /// Child class must implement this method
		/// </summary>
		/// <param name=""></param>
		/// <returns></returns>
      protected abstract void DoWork();

      /// <summary>
		/// Tells thread to quit
		/// </summary>
		/// <param name=""></param>
		/// <returns></returns>
      public virtual void Quit() { }

      /// <summary>
		/// Wait for thread to exit
		/// </summary>
		/// <param name=""></param>
		/// <returns></returns>
      public virtual void WaitForExit() 
      { 
         if (_thread != null)
         {
            // wait for thread to terminate
            _thread.Join();
         }
      }
   }
}
