private CancelIoEx ( |
||
hFile | ||
lpOverlapped | ||
return | bool |
public void CancelIO() { if (IsOpen) { NativeMethods.CancelIoEx(safeReadHandle.DangerousGetHandle(), IntPtr.Zero); } }
private static void CloseDeviceIO(IntPtr handle) { if (Environment.OSVersion.Version.Major > 5) { NativeMethods.CancelIoEx(handle, IntPtr.Zero); } NativeMethods.CloseHandle(handle); }
private void DeviceEventMonitorRemoved() { if (IsOpen) { lock (this) { idleTicks = 100; } MonitorDeviceEvents = false; Console.WriteLine("Cancelling IO"); NativeMethods.CancelIoEx(safeReadHandle.DangerousGetHandle(), IntPtr.Zero); Console.WriteLine("Cancelled IO"); CloseDevice(); Console.WriteLine("Device is closed."); } if (Removed != null) { Removed(); } if (Remove != null) { Remove(this, new EventArgs()); } }
private static void CloseDeviceIO(IntPtr handle) { NativeMethods.CancelIoEx(handle, IntPtr.Zero); NativeMethods.CloseHandle(handle); }