title: Custom initialization functions with IDisposable
body: <p>In .NET (C#) I follow some custom conventions and patterns that require Constructors, Initialization functions and IDisposable implementations. A typical class is illustrated below. No initialization is done directly in the constructor but rather through a dedicated function that is supposed to make the object reusable. However, I am not sure what happens when Dispose gets called. If the GC calls it, the reference to the object is lost anyways so no worries there. If it is explicitly called, are there any drawbacks simply calling Initialize and treating the class as a fresh object since GC.SupressFinalize has been called? Lol, I'm sure I could have asked this in an easier way.</p>
  
  <pre><code>public abstract class Thread: System.IDisposable
  {
  
      protected bool Disposed { get; set; }
      protected bool Terminate { get; private set; }
      public bool IsRunning { get; private set; }
      private System.Threading.Thread ThreadObject { get; set; }
  
      public Thread ()
      {
          this.Initialize();
      }
  
      ~Thread ()
      {
          this.Dispose(false);
      }
  
      public virtual void Initialize ()
      {
          this.Stop();
  
          this.Disposed = false;
          this.Terminate = true;
          this.IsRunning = false;
          this.ThreadObject = null;
      }
  
      //====================================================================================================
      // Functions: Thread
      //====================================================================================================
  
      public void Start ()
      {
          if (!this.IsRunning)
          {
              this.IsRunning = true;
              this.Terminate = false;
  
              this.ThreadObject = new System.Threading.Thread(new System.Threading.ThreadStart(this.Process));
              this.ThreadObject.Start();
          }
      }
  
      /// &lt;summary&gt;
      /// Override this method to do thread processing.
      /// [this.Terminate] will be set to indicate that Stop has been called.
      /// &lt;/summary&gt;
      /// &lt;param name="template"&gt;&lt;/param&gt;
      protected abstract void Process ();
  
      public void Stop (System.TimeSpan timeout)
      {
          if (this.IsRunning)
          {
              this.Terminate = true;
  
              try
              {
                  if (timeout.TotalMilliseconds &gt; 1D)
                  {
                      this.ThreadObject.Join(timeout);
                  }
                  else
                  {
                      this.ThreadObject.Join();
                  }
              }
              catch
              {
                  try
                  {
                      this.ThreadObject.Abort();
                  }
                  catch
                  {
                  }
              }
  
              this.ThreadObject = null;
              this.IsRunning = false;
          }
      }
  
      //====================================================================================================
      // Interface Implementation: System.IDisposable
      //====================================================================================================
  
      public void Dispose ()
      {
          this.Dispose(true);
  
          System.GC.SuppressFinalize(this);
      }
  
      protected virtual void Dispose (bool disposing)
      {
          if (!this.Disposed)
          {
              if (disposing)
              {
                  // Dispose managed resources.
                  this.Stop(System.TimeSpan.FromSeconds(1));
              }
  
              // Dispose unmanaged resources here.
  
              // Note disposing has been done.
              this.Disposed = true;
          }
      }
  
  }
  </code></pre>