System.Runtime.InteropServices.CriticalHandle.Cleanup C# (CSharp) Method

Cleanup() private method

private Cleanup ( ) : void
return void
    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);
    }