本文整理汇总了C#中System.Data.SqlClient.TdsParserStateObject.IncrementPendingCallbacks方法的典型用法代码示例。如果您正苦于以下问题:C# TdsParserStateObject.IncrementPendingCallbacks方法的具体用法?C# TdsParserStateObject.IncrementPendingCallbacks怎么用?C# TdsParserStateObject.IncrementPendingCallbacks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.TdsParserStateObject
的用法示例。
在下文中一共展示了TdsParserStateObject.IncrementPendingCallbacks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnableMars
internal void EnableMars()
{
if (_fMARS)
{
// Cache physical stateObj and connection.
_pMarsPhysicalConObj = _physicalStateObj;
UInt32 error = 0;
// Add SMUX (MARS) SNI provider.
UInt32 info = 0;
error = SNINativeMethodWrapper.SNIAddProvider(_pMarsPhysicalConObj.Handle, SNINativeMethodWrapper.ProviderEnum.SMUX_PROV, ref info);
if (error != TdsEnums.SNI_SUCCESS)
{
_physicalStateObj.AddError(ProcessSNIError(_physicalStateObj));
ThrowExceptionAndWarning(_physicalStateObj);
}
// HACK HACK HACK - for Async only
// Have to post read to intialize MARS - will get callback on this when connection goes
// down or is closed.
IntPtr temp = IntPtr.Zero;
try { }
finally
{
_pMarsPhysicalConObj.IncrementPendingCallbacks();
error = SNINativeMethodWrapper.SNIReadAsync(_pMarsPhysicalConObj.Handle, ref temp);
if (temp != IntPtr.Zero)
{
// Be sure to release packet, otherwise it will be leaked by native.
SNINativeMethodWrapper.SNIPacketRelease(temp);
}
}
Debug.Assert(IntPtr.Zero == temp, "unexpected syncReadPacket without corresponding SNIPacketRelease");
if (TdsEnums.SNI_SUCCESS_IO_PENDING != error)
{
Debug.Assert(TdsEnums.SNI_SUCCESS != error, "Unexpected successfull read async on physical connection before enabling MARS!");
_physicalStateObj.AddError(ProcessSNIError(_physicalStateObj));
ThrowExceptionAndWarning(_physicalStateObj);
}
_physicalStateObj = CreateSession(); // Create and open default MARS stateObj and connection.
}
}
示例2: ReadSni
internal void ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
{
if ((this._parser.State != TdsParserState.Broken) && (this._parser.State != TdsParserState.Closed))
{
IntPtr zero = IntPtr.Zero;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
uint num;
if (!this._parser.AsyncOn)
{
num = SNINativeMethodWrapper.SNIReadSync(stateObj.Handle, ref zero, TdsParserStaticMethods.GetTimeoutMilliseconds(stateObj.TimeoutTime));
if (num == 0)
{
stateObj.ProcessSniPacket(zero, 0);
}
else
{
this.ReadSniError(stateObj, num);
}
}
else
{
stateObj._asyncResult = asyncResult;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
}
finally
{
stateObj.IncrementPendingCallbacks();
num = SNINativeMethodWrapper.SNIReadAsync(stateObj.Handle, ref zero);
if ((num != 0) && (0x3e5 != num))
{
stateObj.DecrementPendingCallbacks(false);
}
}
if (num == 0)
{
stateObj._asyncResult.SetCompletedSynchronously();
stateObj.ReadAsyncCallback(ADP.PtrZero, zero, 0);
}
else if (0x3e5 != num)
{
this.ReadSniError(stateObj, num);
}
}
}
finally
{
if (zero != IntPtr.Zero)
{
SNINativeMethodWrapper.SNIPacketRelease(zero);
}
}
}
}