Esempio n. 1
0
        static async Task TryPeekQueueSize(TableBasedQueue tableBasedQueue, SqlConnectionFactory sqlConnectionFactory)
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled))
            {
                using (var connection = await sqlConnectionFactory.OpenNewConnection())
                    using (var tx = connection.BeginTransaction())
                    {
                        await tableBasedQueue.TryPeek(connection, tx, CancellationToken.None, PeekTimeoutInSeconds);

                        scope.Complete();
                    }
            }
        }
Esempio n. 2
0
        static async Task TryPeekQueueSize(TableBasedQueue tableBasedQueue, SqlConnectionFactory sqlConnectionFactory, CancellationToken cancellationToken = default)
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled))
            {
                using (var connection = await sqlConnectionFactory.OpenNewConnection(cancellationToken))
                    using (var tx = connection.BeginTransaction())
                    {
                        tableBasedQueue.FormatPeekCommand(100);
                        await tableBasedQueue.TryPeek(connection, tx, PeekTimeoutInSeconds, cancellationToken);

                        scope.Complete();
                    }
            }
        }
 static async Task TryPeekQueueSize(TableBasedQueue tableBasedQueue)
 {
     await ExecuteInTransactionScope(async c => {
         await tableBasedQueue.TryPeek(c, CancellationToken.None, PeekTimeoutInSeconds);
     });
 }