using System;
using System.Runtime.ConstrainedExecution;
namespace System.Runtime.InteropServices
{
/// Represents a wrapper class for handle resources.
// Token: 0x02000305 RID: 773
public abstract class CriticalHandle : CriticalFinalizerObject, IDisposable
{
/// Initializes a new instance of the class with the specified invalid handle value.
/// The value of an invalid handle (usually 0 or -1).
/// The derived class resides in an assembly without unmanaged code access permission.
// Token: 0x060021E0 RID: 8672 RVA: 0x00079274 File Offset: 0x00077474
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandle(IntPtr invalidHandleValue)
{
this.handle = invalidHandleValue;
}
/// Frees all resources associated with the handle.
// Token: 0x060021E1 RID: 8673 RVA: 0x00079284 File Offset: 0x00077484
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
~CriticalHandle()
{
this.Dispose(false);
}
/// Marks the handle for releasing and freeing resources.
///
///
///
// Token: 0x060021E2 RID: 8674 RVA: 0x000792C0 File Offset: 0x000774C0
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Close()
{
this.Dispose(true);
}
/// Releases all resources used by the .
///
///
///
// Token: 0x060021E3 RID: 8675 RVA: 0x000792CC File Offset: 0x000774CC
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void Dispose()
{
this.Dispose(true);
}
/// Releases the unmanaged resources used by the class specifying whether to perform a normal dispose operation.
/// true for a normal dispose operation; false to finalize the handle.
// Token: 0x060021E4 RID: 8676 RVA: 0x000792D8 File Offset: 0x000774D8
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected virtual void Dispose(bool disposing)
{
if (this._disposed)
{
return;
}
this._disposed = true;
if (this.IsInvalid)
{
return;
}
if (disposing && !this.IsInvalid && !this.ReleaseHandle())
{
GC.SuppressFinalize(this);
}
}
/// When overridden in a derived class, executes the code required to free the handle.
/// true if the handle is released successfully; otherwise, in the event of a catastrophic failure, false. In this case, it generates a releaseHandleFailed MDA Managed Debugging Assistant.
// Token: 0x060021E5 RID: 8677
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected abstract bool ReleaseHandle();
/// Sets the handle to the specified pre-existing handle.
/// The pre-existing handle to use.
// Token: 0x060021E6 RID: 8678 RVA: 0x0007932C File Offset: 0x0007752C
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected void SetHandle(IntPtr handle)
{
this.handle = handle;
}
/// Marks a handle as invalid.
///
///
///
// Token: 0x060021E7 RID: 8679 RVA: 0x00079338 File Offset: 0x00077538
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void SetHandleAsInvalid()
{
this._disposed = true;
}
/// Gets a value indicating whether the handle is closed.
/// true if the handle is closed; otherwise, false.
///
///
///
// Token: 0x17000646 RID: 1606
// (get) Token: 0x060021E8 RID: 8680 RVA: 0x00079344 File Offset: 0x00077544
public bool IsClosed
{
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get
{
return this._disposed;
}
}
/// When overridden in a derived class, gets a value indicating whether the handle value is invalid.
/// true if the handle is valid; otherwise, false.
///
///
///
// Token: 0x17000647 RID: 1607
// (get) Token: 0x060021E9 RID: 8681
public abstract bool IsInvalid
{
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
get;
}
/// Specifies the handle to be wrapped.
// Token: 0x04000CF7 RID: 3319
protected IntPtr handle;
// Token: 0x04000CF8 RID: 3320
private bool _disposed;
}
}