title: How to force a method to be called at some point
body: <p>I have an object implementing <code>IDisposable</code>and I want to do some job on the Dispose involving others objects. How can I be sure  that this job is performed. Currently the processing is done inside a if. I can not remove it outside the if, right ?</p>
  
  <p>NB : _innerObject may or may continue to live after MyClass instance is dead.</p>
  
  <pre><code>    private OtherClass _innerObject;
      ~MyClass()
      {
          Dispose(false);
      }
  
      public void Dispose()
      {
          Dispose(true);
          GC.SuppressFinalize(this);
      }
  
      private void Dispose(bool disposing)
      {
          if (_disposed)
              return;
  
          if (disposing)
          {
              _innerObject.DoSomeJob();
          }
          _disposed = true;
      }
  </code></pre>