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


C# TdsParserStateObject.ProcessSniPacket方法代码示例

本文整理汇总了C#中System.Data.SqlClient.TdsParserStateObject.ProcessSniPacket方法的典型用法代码示例。如果您正苦于以下问题:C# TdsParserStateObject.ProcessSniPacket方法的具体用法?C# TdsParserStateObject.ProcessSniPacket怎么用?C# TdsParserStateObject.ProcessSniPacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlClient.TdsParserStateObject的用法示例。


在下文中一共展示了TdsParserStateObject.ProcessSniPacket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadSniError

 private void ReadSniError(TdsParserStateObject stateObj, uint error)
 {
     if (this._parser._fAwaitingPreLogin && (error != 0x102))
     {
         this._parser._fPreLoginErrorOccurred = true;
         return;
     }
     if (0x102 != error)
     {
         this._parser.Errors.Add(this._parser.ProcessSNIError(stateObj));
         goto Label_011E;
     }
     bool flag = false;
     if (this._internalTimeout)
     {
         flag = true;
     }
     else
     {
         stateObj._internalTimeout = true;
         this._parser.Errors.Add(new SqlError(-2, 0, 11, this._parser.Server, SQLMessage.Timeout(), "", 0));
         if (!stateObj._attentionSent)
         {
             if (stateObj.Parser.State == TdsParserState.OpenLoggedIn)
             {
                 stateObj.SendAttention();
                 IntPtr zero = IntPtr.Zero;
                 RuntimeHelpers.PrepareConstrainedRegions();
                 try
                 {
                     error = SNINativeMethodWrapper.SNIReadSync(stateObj.Handle, ref zero, TdsParserStaticMethods.GetTimeoutMilliseconds(stateObj.TimeoutTime));
                     if (error == 0)
                     {
                         stateObj.ProcessSniPacket(zero, 0);
                         return;
                     }
                     flag = true;
                     goto Label_00E1;
                 }
                 finally
                 {
                     if (zero != IntPtr.Zero)
                     {
                         SNINativeMethodWrapper.SNIPacketRelease(zero);
                     }
                 }
             }
             flag = true;
         }
     }
 Label_00E1:
     if (flag)
     {
         this._parser.State = TdsParserState.Broken;
         this._parser.Connection.BreakConnection();
     }
 Label_011E:
     this._parser.ThrowExceptionAndWarning();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:59,代码来源:TdsParserStateObject.cs

示例2: ReadSniError

        // This method should only be called by ReadSni!  If not - it may have problems with timeouts!
        private void ReadSniError(TdsParserStateObject stateObj, UInt32 error)
        {
            if (TdsEnums.SNI_WAIT_TIMEOUT == error)
            {
                Debug.Assert(_syncOverAsync, "Should never reach here with async on!");
                bool fail = false;

                if (_internalTimeout)
                { // This is now our second timeout - time to give up.
                    fail = true;
                }
                else
                {
                    stateObj._internalTimeout = true;
                    Debug.Assert(_parser.Connection != null, "SqlConnectionInternalTds handler can not be null at this point.");
                    AddError(new SqlError(TdsEnums.TIMEOUT_EXPIRED, (byte)0x00, TdsEnums.MIN_ERROR_CLASS, _parser.Server, _parser.Connection.TimeoutErrorInternal.GetErrorMessage(), "", 0, TdsEnums.SNI_WAIT_TIMEOUT));

                    if (!stateObj._attentionSent)
                    {
                        if (stateObj.Parser.State == TdsParserState.OpenLoggedIn)
                        {
                            stateObj.SendAttention(mustTakeWriteLock: true);

                            IntPtr syncReadPacket = IntPtr.Zero;

                            bool shouldDecrement = false;
                            try
                            {
                                Interlocked.Increment(ref _readingCount);
                                shouldDecrement = true;

                                SNIHandle handle = Handle;
                                if (handle == null)
                                {
                                    throw ADP.ClosedConnectionError();
                                }

                                error = SNINativeMethodWrapper.SNIReadSyncOverAsync(handle, ref syncReadPacket, stateObj.GetTimeoutRemaining());

                                Interlocked.Decrement(ref _readingCount);
                                shouldDecrement = false;

                                if (TdsEnums.SNI_SUCCESS == error)
                                {
                                    // We will end up letting the run method deal with the expected done:done_attn token stream.
                                    stateObj.ProcessSniPacket(syncReadPacket, 0);
                                    return;
                                }
                                else
                                {
                                    Debug.Assert(IntPtr.Zero == syncReadPacket, "unexpected syncReadPacket without corresponding SNIPacketRelease");
                                    fail = true; // Subsequent read failed, time to give up.
                                }
                            }
                            finally
                            {
                                if (shouldDecrement)
                                {
                                    Interlocked.Decrement(ref _readingCount);
                                }

                                if (syncReadPacket != IntPtr.Zero)
                                {
                                    // Be sure to release packet, otherwise it will be leaked by native.
                                    SNINativeMethodWrapper.SNIPacketRelease(syncReadPacket);
                                }
                            }
                        }
                        else
                        {
                            if (_parser._loginWithFailover)
                            {
                                // For DbMirroring Failover during login, never break the connection, just close the TdsParser
                                _parser.Disconnect();
                            }
                            else if ((_parser.State == TdsParserState.OpenNotLoggedIn) && (_parser.Connection.ConnectionOptions.MultiSubnetFailover))
                            {
                                // For MultiSubnet Failover during login, never break the connection, just close the TdsParser
                                _parser.Disconnect();
                            }
                            else
                                fail = true; // We aren't yet logged in - just fail.
                        }
                    }
                }

                if (fail)
                {
                    _parser.State = TdsParserState.Broken; // We failed subsequent read, we have to quit!
                    _parser.Connection.BreakConnection();
                }
            }
            else
            {
                // Caution: ProcessSNIError  always  returns a fatal error!
                AddError(_parser.ProcessSNIError(stateObj));
            }
            ThrowExceptionAndWarning();

//.........这里部分代码省略.........
开发者ID:nnyamhon,项目名称:corefx,代码行数:101,代码来源:TdsParserStateObject.cs

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