private void Cleanup()
{
if (IsClosed)
return;
_isClosed = true;
if (IsInvalid)
return;
// Save last error from P/Invoke in case the implementation of
// ReleaseHandle trashes it (important because this ReleaseHandle could
// occur implicitly as part of unmarshaling another P/Invoke).
int lastError = Marshal.GetLastWin32Error();
if (!ReleaseHandle())
FireCustomerDebugProbe();
Marshal.SetLastWin32Error(lastError);
GC.SuppressFinalize(this);
}