Esempio n. 1
0
        private void Cancel()
        {
            // Storing to locals to avoid data ----s
            SafeHandle        handle     = this._handle;
            NativeOverlapped *overlapped = this._overlapped;

            if (handle != null && !handle.IsInvalid && overlapped != null)
            {
                if (!UnsafeNativeMethods.CancelIoEx(handle, overlapped))
                {
                    // This case should not have any consequences although
                    // it will be easier to debug if there exists any special case
                    // we are not aware of.
                    int errorCode = Marshal.GetLastWin32Error();
                    Debug.WriteLine("CancelIoEx finished with error code {0}.", errorCode);
                }
                SetOperationCompleted();
            }
        }