Files
Dec2017-Script-Dump/mscorlib/System/Threading/Overlapped.cs
T
2026-06-04 11:42:34 +02:00

264 lines
14 KiB
C#

using System;
using System.Runtime.InteropServices;
namespace System.Threading
{
/// <summary>Provides a managed representation of a Win32 OVERLAPPED structure, including methods to transfer information from an <see cref="T:System.Threading.Overlapped" /> instance to a <see cref="T:System.Threading.NativeOverlapped" /> structure.</summary>
/// <filterpriority>2</filterpriority>
// Token: 0x02000619 RID: 1561
[ComVisible(true)]
public class Overlapped
{
/// <summary>Initializes a new, empty instance of the <see cref="T:System.Threading.Overlapped" /> class.</summary>
// Token: 0x060038F6 RID: 14582 RVA: 0x000C4814 File Offset: 0x000C2A14
public Overlapped()
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Threading.Overlapped" /> class with the specified file position, the 32-bit integer handle to an event that is signaled when the I/O operation is complete, and an interface through which to return the results of the operation.</summary>
/// <param name="offsetLo">The low word of the file position at which to start the transfer. </param>
/// <param name="offsetHi">The high word of the file position at which to start the transfer. </param>
/// <param name="hEvent">The handle to an event that is signaled when the I/O operation is complete. </param>
/// <param name="ar">An object that implements the <see cref="T:System.IAsyncResult" /> interface and provides status information on the I/O operation. </param>
// Token: 0x060038F7 RID: 14583 RVA: 0x000C481C File Offset: 0x000C2A1C
[Obsolete("Not 64bit compatible. Please use the constructor that takes IntPtr for the event handle", false)]
public Overlapped(int offsetLo, int offsetHi, int hEvent, IAsyncResult ar)
{
this.offsetL = offsetLo;
this.offsetH = offsetHi;
this.evt = hEvent;
this.ares = ar;
}
/// <summary>Initializes a new instance of the <see cref="T:System.Threading.Overlapped" /> class with the specified file position, the handle to an event that is signaled when the I/O operation is complete, and an interface through which to return the results of the operation.</summary>
/// <param name="offsetLo">The low word of the file position at which to start the transfer. </param>
/// <param name="offsetHi">The high word of the file position at which to start the transfer. </param>
/// <param name="hEvent">The handle to an event that is signaled when the I/O operation is complete. </param>
/// <param name="ar">An object that implements the <see cref="T:System.IAsyncResult" /> interface and provides status information on the I/O operation. </param>
// Token: 0x060038F8 RID: 14584 RVA: 0x000C4844 File Offset: 0x000C2A44
public Overlapped(int offsetLo, int offsetHi, IntPtr hEvent, IAsyncResult ar)
{
this.offsetL = offsetLo;
this.offsetH = offsetHi;
this.evt_ptr = hEvent;
this.ares = ar;
}
/// <summary>Frees the unmanaged memory associated with a native overlapped structure allocated by the <see cref="Overload:System.Threading.Overlapped.Pack" /> method.</summary>
/// <param name="nativeOverlappedPtr">A pointer to the <see cref="T:System.Threading.NativeOverlapped" /> structure to be freed.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="nativeOverlappedPtr" /> is null.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060038F9 RID: 14585 RVA: 0x000C486C File Offset: 0x000C2A6C
[CLSCompliant(false)]
public unsafe static void Free(NativeOverlapped* nativeOverlappedPtr)
{
if ((IntPtr)((void*)nativeOverlappedPtr) == IntPtr.Zero)
{
throw new ArgumentNullException("nativeOverlappedPtr");
}
Marshal.FreeHGlobal((IntPtr)((void*)nativeOverlappedPtr));
}
/// <summary>Unpacks the specified unmanaged <see cref="T:System.Threading.NativeOverlapped" /> structure into a managed <see cref="T:System.Threading.Overlapped" /> object. </summary>
/// <returns>An <see cref="T:System.Threading.Overlapped" /> object containing the information unpacked from the native structure.</returns>
/// <param name="nativeOverlappedPtr">An unmanaged pointer to a <see cref="T:System.Threading.NativeOverlapped" /> structure.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="nativeOverlappedPtr" /> is null.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060038FA RID: 14586 RVA: 0x000C489C File Offset: 0x000C2A9C
[CLSCompliant(false)]
public unsafe static Overlapped Unpack(NativeOverlapped* nativeOverlappedPtr)
{
if ((IntPtr)((void*)nativeOverlappedPtr) == IntPtr.Zero)
{
throw new ArgumentNullException("nativeOverlappedPtr");
}
return new Overlapped
{
offsetL = nativeOverlappedPtr->OffsetLow,
offsetH = nativeOverlappedPtr->OffsetHigh,
evt = (int)nativeOverlappedPtr->EventHandle
};
}
/// <summary>Packs the current instance into a <see cref="T:System.Threading.NativeOverlapped" /> structure, specifying the delegate to be invoked when the asynchronous I/O operation is complete.</summary>
/// <returns>An unmanaged pointer to a <see cref="T:System.Threading.NativeOverlapped" /> structure. </returns>
/// <param name="iocb">An <see cref="T:System.Threading.IOCompletionCallback" /> delegate that represents the callback method invoked when the asynchronous I/O operation completes.</param>
/// <exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Threading.Overlapped" /> has already been packed.</exception>
/// <filterpriority>2</filterpriority>
// Token: 0x060038FB RID: 14587 RVA: 0x000C48FC File Offset: 0x000C2AFC
[MonoTODO("Security - we need to propagate the call stack")]
[Obsolete("Use Pack(iocb, userData) instead", false)]
[CLSCompliant(false)]
public unsafe NativeOverlapped* Pack(IOCompletionCallback iocb)
{
NativeOverlapped* ptr = (NativeOverlapped*)(void*)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NativeOverlapped)));
ptr->OffsetLow = this.offsetL;
ptr->OffsetHigh = this.offsetH;
ptr->EventHandle = (IntPtr)this.evt;
return ptr;
}
/// <summary>Packs the current instance into a <see cref="T:System.Threading.NativeOverlapped" /> structure, specifying a delegate that is invoked when the asynchronous I/O operation is complete and a managed object that serves as a buffer.</summary>
/// <returns>An unmanaged pointer to a <see cref="T:System.Threading.NativeOverlapped" /> structure. </returns>
/// <param name="iocb">An <see cref="T:System.Threading.IOCompletionCallback" /> delegate that represents the callback method invoked when the asynchronous I/O operation completes.</param>
/// <param name="userData">An object or array of objects representing the input or output buffer for the operation. Each object represents a buffer, for example an array of bytes.</param>
/// <exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Threading.Overlapped" /> has already been packed.</exception>
/// <filterpriority>2</filterpriority>
// Token: 0x060038FC RID: 14588 RVA: 0x000C4950 File Offset: 0x000C2B50
[MonoTODO("handle userData")]
[CLSCompliant(false)]
[ComVisible(false)]
public unsafe NativeOverlapped* Pack(IOCompletionCallback iocb, object userData)
{
NativeOverlapped* ptr = (NativeOverlapped*)(void*)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NativeOverlapped)));
ptr->OffsetLow = this.offsetL;
ptr->OffsetHigh = this.offsetH;
ptr->EventHandle = this.evt_ptr;
return ptr;
}
/// <summary>Packs the current instance into a <see cref="T:System.Threading.NativeOverlapped" /> structure specifying the delegate to invoke when the asynchronous I/O operation is complete. Does not propagate the calling stack.</summary>
/// <returns>An unmanaged pointer to a <see cref="T:System.Threading.NativeOverlapped" /> structure. </returns>
/// <param name="iocb">An <see cref="T:System.Threading.IOCompletionCallback" /> delegate that represents the callback method invoked when the asynchronous I/O operation completes.</param>
/// <exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Threading.Overlapped" /> has already been packed.</exception>
/// <filterpriority>2</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x060038FD RID: 14589 RVA: 0x000C499C File Offset: 0x000C2B9C
[Obsolete("Use UnsafePack(iocb, userData) instead", false)]
[CLSCompliant(false)]
public unsafe NativeOverlapped* UnsafePack(IOCompletionCallback iocb)
{
return this.Pack(iocb);
}
/// <summary>Packs the current instance into a <see cref="T:System.Threading.NativeOverlapped" /> structure, specifying the delegate to invoke when the asynchronous I/O operation is complete and the managed object that serves as a buffer. Does not propagate the calling stack.</summary>
/// <returns>An unmanaged pointer to a <see cref="T:System.Threading.NativeOverlapped" /> structure. </returns>
/// <param name="iocb">An <see cref="T:System.Threading.IOCompletionCallback" /> delegate that represents the callback method invoked when the asynchronous I/O operation completes.</param>
/// <param name="userData">An object or array of objects representing the input or output buffer for the operation. Each object represents a buffer, for example an array of bytes.</param>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Threading.Overlapped" /> is already packed.</exception>
/// <filterpriority>2</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence, ControlPolicy" />
/// </PermissionSet>
// Token: 0x060038FE RID: 14590 RVA: 0x000C49A8 File Offset: 0x000C2BA8
[ComVisible(false)]
[CLSCompliant(false)]
public unsafe NativeOverlapped* UnsafePack(IOCompletionCallback iocb, object userData)
{
return this.Pack(iocb, userData);
}
/// <summary>Gets or sets the object that provides status information on the I/O operation.</summary>
/// <returns>An object that implements the <see cref="T:System.IAsyncResult" /> interface.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x17000B03 RID: 2819
// (get) Token: 0x060038FF RID: 14591 RVA: 0x000C49B4 File Offset: 0x000C2BB4
// (set) Token: 0x06003900 RID: 14592 RVA: 0x000C49BC File Offset: 0x000C2BBC
public IAsyncResult AsyncResult
{
get
{
return this.ares;
}
set
{
this.ares = value;
}
}
/// <summary>Gets or sets the 32-bit integer handle to a synchronization event that is signaled when the I/O operation is complete.</summary>
/// <returns>An <see cref="T:System.Int32" /> value representing the handle of the synchronization event.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x17000B04 RID: 2820
// (get) Token: 0x06003901 RID: 14593 RVA: 0x000C49C8 File Offset: 0x000C2BC8
// (set) Token: 0x06003902 RID: 14594 RVA: 0x000C49D0 File Offset: 0x000C2BD0
[Obsolete("Not 64bit compatible. Use EventHandleIntPtr instead.", false)]
public int EventHandle
{
get
{
return this.evt;
}
set
{
this.evt = value;
}
}
/// <summary>Gets or sets the handle to the synchronization event that is signaled when the I/O operation is complete.</summary>
/// <returns>An <see cref="T:System.IntPtr" /> representing the handle of the event.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x17000B05 RID: 2821
// (get) Token: 0x06003903 RID: 14595 RVA: 0x000C49DC File Offset: 0x000C2BDC
// (set) Token: 0x06003904 RID: 14596 RVA: 0x000C49E4 File Offset: 0x000C2BE4
[ComVisible(false)]
public IntPtr EventHandleIntPtr
{
get
{
return this.evt_ptr;
}
set
{
this.evt_ptr = value;
}
}
/// <summary>Gets or sets the high-order word of the file position at which to start the transfer. The file position is a byte offset from the start of the file.</summary>
/// <returns>An <see cref="T:System.Int32" /> value representing the high word of the file position.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x17000B06 RID: 2822
// (get) Token: 0x06003905 RID: 14597 RVA: 0x000C49F0 File Offset: 0x000C2BF0
// (set) Token: 0x06003906 RID: 14598 RVA: 0x000C49F8 File Offset: 0x000C2BF8
public int OffsetHigh
{
get
{
return this.offsetH;
}
set
{
this.offsetH = value;
}
}
/// <summary>Gets or sets the low-order word of the file position at which to start the transfer. The file position is a byte offset from the start of the file.</summary>
/// <returns>An <see cref="T:System.Int32" /> value representing the low word of the file position.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x17000B07 RID: 2823
// (get) Token: 0x06003907 RID: 14599 RVA: 0x000C4A04 File Offset: 0x000C2C04
// (set) Token: 0x06003908 RID: 14600 RVA: 0x000C4A0C File Offset: 0x000C2C0C
public int OffsetLow
{
get
{
return this.offsetL;
}
set
{
this.offsetL = value;
}
}
// Token: 0x040016F8 RID: 5880
private IAsyncResult ares;
// Token: 0x040016F9 RID: 5881
private int offsetL;
// Token: 0x040016FA RID: 5882
private int offsetH;
// Token: 0x040016FB RID: 5883
private int evt;
// Token: 0x040016FC RID: 5884
private IntPtr evt_ptr;
}
}