public override uint SendAsync(SNIPacket packet, SNIAsyncCallback callback = null)
{
SNIPacket newPacket = packet;
_writeTaskFactory.StartNew(() =>
{
try
{
lock (this)
{
packet.WriteToStream(_stream);
}
}
catch (Exception e)
{
SNILoadHandle.SingletonInstance.LastError = new SNIError(SNIProviders.TCP_PROV, SNICommon.InternalExceptionError, e);
if (callback != null)
{
callback(packet, TdsEnums.SNI_ERROR);
}
else
{
_sendCallback(packet, TdsEnums.SNI_ERROR);
}
return;
}
if (callback != null)
{
callback(packet, TdsEnums.SNI_SUCCESS);
}
else
{
_sendCallback(packet, TdsEnums.SNI_SUCCESS);
}
});
return TdsEnums.SNI_SUCCESS_IO_PENDING;
}