protected override void Dispose(bool disposing)
{
if (!_disposed)
{
_disposed = true;
if (disposing)
{
// TODO (Issue 2508): Pinned buffers must be released in the callback, when it is guaranteed no further
// operations will be made to the send/receive buffers.
if (_cachedReceivePinnedBuffer.IsAllocated)
{
_cachedReceivePinnedBuffer.Free();
}
if (_state.RequestHandle != null)
{
_state.RequestHandle.Dispose();
_state.RequestHandle = null;
}
_state.Dispose();
}
}
base.Dispose(disposing);
}