/// <summary> /// Creates an event object for the overlapped structure used with /// ReadFile. Called before the first call to ReadFile. /// </summary> /// /// <param name="hidOverlapped"> the overlapped structure </param> /// <param name="eventObject"> the event object </param> public void PrepareForOverlappedTransfer(ref FileIO.OVERLAPPED hidOverlapped, ref SafeWaitHandle eventObject) { try { // *** // API function: CreateEvent // Purpose: Creates an event object for the overlapped structure used with ReadFile. // Accepts: // A security attributes structure. // Manual Reset = False (The system automatically resets the state to nonsignaled // after a waiting thread has been released.) // Initial state = True (signaled) // An event object name (optional) // Returns: a handle to the event object // *** eventObject = FileIO.CreateEvent(null, System.Convert.ToInt32(false), System.Convert.ToInt32(true), ""); // Debug.WriteLine(MyDebugging.ResultOfAPICall("CreateEvent")) // Set the members of the overlapped structure. hidOverlapped.Offset = 0; hidOverlapped.OffsetHigh = 0; hidOverlapped.hEvent = eventObject; readyForOverlappedTransfer = true; } catch ( Exception ex ) { DisplayException( MODULE_NAME, ex ); throw ; } }