Parameter 'fromFinalizer' is only used for precondition check(s) - what does this mean?

I have a class containing this C# code:

~MyClass() {
  Dispose(fromFinalizer: true);
}

public void Dispose() {
  Dispose(fromFinalizer: false);
}

private void Dispose(bool fromFinalizer) {
  if (this.IsDisposed) {
    return;
  }

  // Make sure this instance is only disposed on the thread it was created.
  // Exception: Allow this when Dispose() is called by the finalized, which normally runs on a different thread.
  if (!fromFinalizer && Thread.CurrentThread != this.m_creatorThread) {
    throw new InvalidOperationException("Instance can only be disposed on the creator thread.");
  }

  this.Handle = IntPtr.Zero;
  if (this.Disposed != null) {
    this.Disposed(this);
  }
}


In "Dispose(bool fromFinalizer)" ReSharper says:

Parameter 'fromFinalizer' is only used for precondition check(s)


What does that mean, or - to be more precise - why is this a warning?

- Sebastian

Please sign in to leave a comment.