Exemple #1
0
        async Task DispatchIsolated(SortingResult sortedOperations)
        {
            if (sortedOperations.IsolatedDispatch == null)
            {
                return;
            }

#if NET452
            using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, TransactionScopeAsyncFlowOption.Enabled))
                using (var connection = await connectionFactory.OpenNewConnection().ConfigureAwait(false))
                {
                    await Dispatch(sortedOperations.IsolatedDispatch, connection, null).ConfigureAwait(false);

                    scope.Complete();
                }
#else
            using (var scope = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled))
                using (var connection = await connectionFactory.OpenNewConnection().ConfigureAwait(false))
                    using (var tx = connection.BeginTransaction())
                    {
                        await Dispatch(sortedOperations.IsolatedDispatch, connection, tx).ConfigureAwait(false);

                        tx.Commit();
                        scope.Complete();
                    }
#endif
        }
Exemple #2
0
        async Task DispatchDefault(SortingResult sortedOperations, TransportTransaction transportTransaction)
        {
            if (sortedOperations.DefaultDispatch == null)
            {
                return;
            }

            if (InReceiveWithNoTransactionMode(transportTransaction) || InReceiveOnlyTransportTransactionMode(transportTransaction))
            {
                await DispatchUsingNewConnectionAndTransaction(sortedOperations.DefaultDispatch).ConfigureAwait(false);

                return;
            }

            await DispatchUsingReceiveTransaction(transportTransaction, sortedOperations.DefaultDispatch).ConfigureAwait(false);
        }