private static void WriteDispatcher(IntPtr key, IntPtr packet, uint error) { if (IntPtr.Zero != key) { GCHandle handle = (GCHandle)key; TdsParserStateObject target = (TdsParserStateObject)handle.Target; if (target != null) { target.WriteAsyncCallback(IntPtr.Zero, packet, error); } } }
static private void WriteDispatcher(IntPtr key, IntPtr packet, UInt32 error) { // This is the app-domain dispatcher for all async write callbacks, It // simply gets the state object from the key that it is passed, and // calls the state object's write callback. Debug.Assert(IntPtr.Zero != key, "no key passed to write 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.WriteAsyncCallback(IntPtr.Zero, packet, error); } } }
/// <summary> /// Handle send completion /// </summary> public void HandleSendComplete(SNIPacket packet, SNIError sniError) { Debug.Assert(_callbackObject != null); _callbackObject.WriteAsyncCallback(packet, sniError); }