当前位置: 首页>>代码示例>>C#>>正文


C# TdsParserStateObject.IncrementPendingCallbacks方法代码示例

本文整理汇总了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.
            }
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:49,代码来源:TdsParser.cs

示例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);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:57,代码来源:TdsParserStateObject.cs


注:本文中的System.Data.SqlClient.TdsParserStateObject.IncrementPendingCallbacks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。