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


C# NpgsqlConnector.ProcessAndDiscardBackendResponses方法代码示例

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


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

示例1: ExecuteBlindSuppressTimeout

        internal static void ExecuteBlindSuppressTimeout(NpgsqlConnector connector, NpgsqlQuery query)
        {
            // Block the notification thread before writing anything to the wire.
            using (var blocker = connector.BlockNotificationThread())
            {
                // Write the Query message to the wire.
                connector.Query(query);

                // Flush, and wait for and discard all responses.
                connector.ProcessAndDiscardBackendResponses();
            }
        }
开发者ID:baondp,项目名称:Npgsql,代码行数:12,代码来源:NpgsqlCommand.PrepareExecute.cs

示例2: ExecuteBlind

        private static void ExecuteBlind(NpgsqlConnector connector, NpgsqlQuery query, int timeout)
        {
            // Block the notification thread before writing anything to the wire.
            using (var blocker = connector.BlockNotificationThread())
            {
                // Set statement timeout as needed.
                connector.SetBackendCommandTimeout(timeout);

                // Write the Query message to the wire.
                connector.Query(query);

                // Flush, and wait for and discard all responses.
                connector.ProcessAndDiscardBackendResponses();
            }
        }
开发者ID:undeadlabs,项目名称:Npgsql,代码行数:15,代码来源:NpgsqlCommand.PrepareExecute.cs

示例3: ExecuteSetStatementTimeoutBlind

        /// <summary>
        /// Special adaptation of ExecuteBlind() that sets statement_timeout.
        /// This exists to prevent Connector.SetBackendCommandTimeout() from calling Command.ExecuteBlind(),
        /// which will cause an endless recursive loop.
        /// </summary>
        /// <param name="connector"></param>
        /// <param name="timeout">Timeout in seconds.</param>
        internal static void ExecuteSetStatementTimeoutBlind(NpgsqlConnector connector, int timeout)
        {
            NpgsqlQuery query;

            // Optimize for a few common timeout values.
            switch (timeout)
            {
                case 10 :
                    query = NpgsqlQuery.SetStmtTimeout10Sec;
                    break;

                case 20 :
                    query = NpgsqlQuery.SetStmtTimeout20Sec;
                    break;

                case 30 :
                    query = NpgsqlQuery.SetStmtTimeout30Sec;
                    break;

                case 60 :
                    query = NpgsqlQuery.SetStmtTimeout60Sec;
                    break;

                case 90 :
                    query = NpgsqlQuery.SetStmtTimeout90Sec;
                    break;

                case 120 :
                    query = NpgsqlQuery.SetStmtTimeout120Sec;
                    break;

                default :
                    query = new NpgsqlQuery(string.Format("SET statement_timeout = {0}", timeout * 1000));
                    break;

            }

            // Write the Query message to the wire.
            connector.Query(query);

            // Flush, and wait for and discard all responses.
            connector.ProcessAndDiscardBackendResponses();
        }
开发者ID:baondp,项目名称:Npgsql,代码行数:50,代码来源:NpgsqlCommand.PrepareExecute.cs

示例4: ExecuteSetStatementTimeoutBlind

        /// <summary>
        /// Special adaptation of ExecuteBlind() that sets statement_timeout.
        /// This exists to prevent Connector.SetBackendCommandTimeout() from calling Command.ExecuteBlind(),
        /// which will cause an endless recursive loop.
        /// </summary>
        /// <param name="connector"></param>
        /// <param name="timeout">Timeout in seconds.</param>
        internal static void ExecuteSetStatementTimeoutBlind(NpgsqlConnector connector, int timeout)
        {
            NpgsqlQuery query;

            // Bypass cpmmand parsing overhead and send command verbatim.
            query = NpgsqlQuery.Create(connector.BackendProtocolVersion, string.Format("SET statement_timeout = {0}", timeout * 1000));

            // Write the Query message to the wire.
            connector.Query(query);

            // Flush, and wait for and discard all responses.
            connector.ProcessAndDiscardBackendResponses();
        }
开发者ID:undeadlabs,项目名称:Npgsql,代码行数:20,代码来源:NpgsqlCommand.PrepareExecute.cs


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