/// <summary> /// Send packet asynchronously /// </summary> /// <param name="packet">SNI packet</param> /// <param name="callback">Completion callback</param> /// <returns>SNI error code</returns> private uint InternalSendAsync(SNIPacket packet, SNIAsyncCallback callback) { Debug.Assert(packet.ReservedHeaderSize == SNISMUXHeader.HEADER_LENGTH, "mars handle attempting to send muxed packet without mux reservation in InternalSendAsync"); long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent("<sc.SNI.SNIMarsHandle.InternalSendAsync |SNI|INFO|SCOPE>"); try { lock (this) { if (_sequenceNumber >= _sendHighwater) { SqlClientEventSource.Log.SNITraceEvent("<sc.SNI.SNIMarsHandle.InternalSendAsync |SNI|INFO|> SNI Queue is full"); return(TdsEnums.SNI_QUEUE_FULL); } SNIPacket muxedPacket = SetPacketSMUXHeader(packet); muxedPacket.SetCompletionCallback(callback ?? HandleSendComplete); return(_connection.SendAsync(muxedPacket, callback)); } } finally { SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } }
/// <summary> /// Send packet asynchronously /// </summary> /// <param name="packet">SNI packet</param> /// <param name="callback">Completion callback</param> /// <returns>SNI error code</returns> private uint InternalSendAsync(SNIPacket packet, SNIAsyncCallback callback) { Debug.Assert(packet.ReservedHeaderSize == SNISMUXHeader.HEADER_LENGTH, "mars handle attempting to send muxed packet without smux reservation in InternalSendAsync"); long scopeID = SqlClientEventSource.Log.TrySNIScopeEnterEvent("SNIMarsHandle.InternalSendAsync | SNI | INFO | SCOPE | Entering Scope {0}"); try { lock (this) { if (_sequenceNumber >= _sendHighwater) { SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.INFO, "MARS Session Id {0}, _sequenceNumber {1}, _sendHighwater {2}, SNI Queue is full", args0: ConnectionId, args1: _sequenceNumber, args2: _sendHighwater); return(TdsEnums.SNI_QUEUE_FULL); } SNIPacket muxedPacket = SetPacketSMUXHeader(packet); muxedPacket.SetCompletionCallback(callback ?? HandleSendComplete); SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.INFO, "MARS Session Id {0}, _sequenceNumber {1}, _sendHighwater {2}, Sending packet", args0: ConnectionId, args1: _sequenceNumber, args2: _sendHighwater); return(_connection.SendAsync(muxedPacket, callback)); } } finally { SqlClientEventSource.Log.TrySNIScopeLeaveEvent(scopeID); } }
/// <summary> /// Send packet asynchronously /// </summary> /// <param name="packet">SNI packet</param> /// <param name="callback">Completion callback</param> /// <returns>SNI error code</returns> private uint InternalSendAsync(SNIPacket packet, SNIAsyncCallback callback) { lock (this) { if (_sequenceNumber >= _sendHighwater) { return(TdsEnums.SNI_QUEUE_FULL); } SNIPacket encapsulatedPacket = GetSMUXEncapsulatedPacket(packet); if (callback != null) { encapsulatedPacket.SetCompletionCallback(callback); } else { encapsulatedPacket.SetCompletionCallback(HandleSendComplete); } return(_connection.SendAsync(encapsulatedPacket, callback)); } }
/// <summary> /// Send packet asynchronously /// </summary> /// <param name="packet">SNI packet</param> /// <param name="callback">Completion callback</param> /// <returns>SNI error code</returns> private uint InternalSendAsync(SNIPacket packet, SNIAsyncCallback callback) { Debug.Assert(packet.ReservedHeaderSize == SNISMUXHeader.HEADER_LENGTH, "mars handle attempting to send muxed packet without mux reservation in InternalSendAsync"); lock (this) { if (_sequenceNumber >= _sendHighwater) { return(TdsEnums.SNI_QUEUE_FULL); } SNIPacket muxedPacket = SetPacketSMUXHeader(packet); muxedPacket.SetCompletionCallback(callback ?? HandleSendComplete); return(_connection.SendAsync(muxedPacket, callback)); } }