private void CancelOverlapped(SafeFileHandle handle, ManualResetEvent completedEvent) { lock (_cancelIOLock) { if (!completedEvent.WaitOne(OVERLAPPED_TIMEOUT) && handle != null && !handle.IsClosed && !handle.IsInvalid) { InteropKernel32.CancelIo(handle); } } }
public void WriteClear(uint controlCode) { // cancel pending operations lock (_cancelIOLock) { InteropKernel32.CancelIo(_readHandle); InteropKernel32.CancelIo(_writeHandle); } WriteControl(controlCode, null); }