Exemplo n.º 1
0
            ///  <summary>
            ///  Creates an event object for the overlapped structure used with ReadFile.
            ///  </summary>
            ///
            ///  <param name="hidOverlapped"> the overlapped structure </param>
            ///  <param name="eventObject"> the event object </param>

            internal void PrepareForOverlappedTransfer(ref NativeOverlapped hidOverlapped, ref IntPtr eventObject)
            {
                try
                {
                    //  ***
                    //  API function: CreateEvent

                    //  Purpose: Creates an event object for the overlapped structure used with ReadFile.

                    //  Accepts:
                    //  A security attributes structure or IntPtr.Zero.
                    //  Manual Reset = False (The system automatically resets the state to nonsignaled
                    //  after a waiting thread has been released.)
                    //  Initial state = False (not signaled)
                    //  An event object name (optional)

                    //  Returns: a handle to the event object
                    //  ***

                    eventObject = FileIO.CreateEvent(IntPtr.Zero, false, false, "");

                    //  Set the members of the overlapped structure.

                    hidOverlapped.OffsetLow   = 0;
                    hidOverlapped.OffsetHigh  = 0;
                    hidOverlapped.EventHandle = eventObject;
                }
                catch (Exception ex)
                {
                    DisplayException(MODULE_NAME, ex);
                    throw;
                }
            }
Exemplo n.º 2
0
            ///  <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);
                }
            }