Ejemplo n.º 1
0
        internal override PacketHandle ReadSyncOverAsync(int timeoutRemaining, out uint error)
        {
            SNIHandle handle = Handle;

            if (handle == null)
            {
                throw ADP.ClosedConnectionError();
            }
            IntPtr readPacketPtr = IntPtr.Zero;

            error = SNINativeMethodWrapper.SNIReadSyncOverAsync(handle, ref readPacketPtr, GetTimeoutRemaining());
            return(PacketHandle.FromNativePointer(readPacketPtr));
        }
Ejemplo n.º 2
0
        private static void ReadDispatcher(IntPtr key, IntPtr packet, uint error)
        {
            // This is the app-domain dispatcher for all async read callbacks, It
            // simply gets the state object from the key that it is passed, and
            // calls the state object's read callback.
            Debug.Assert(IntPtr.Zero != key, "no key passed to read callback dispatcher?");
            if (IntPtr.Zero != key)
            {
                // NOTE: we will get a null ref here if we don't get a key that
                //       contains a GCHandle to TDSParserStateObject; that is
                //       very bad, and we want that to occur so we can catch it.
                GCHandle             gcHandle = (GCHandle)key;
                TdsParserStateObject stateObj = (TdsParserStateObject)gcHandle.Target;

                if (null != stateObj)
                {
                    stateObj.ReadAsyncCallback(IntPtr.Zero, PacketHandle.FromNativePointer(packet), error);
                }
            }
        }