public void Start() { lock (this.transactionEnlistment.resourceManager.syncRoot) { this.transactionEnlistment.resourceManager.enlistmentMap.Remove(this.transactionEnlistment.transactionId); } try { CompleteTransactionCommand completeTransactionCommand = new CompleteTransactionCommand() { TransactionId = this.transactionEnlistment.transactionId, Timeout = SbmpResourceManager.TransactionEnlistment.rollbackTimeout, Commit = this.commit }; RequestInfo nullable = this.transactionEnlistment.RequestInfo.Clone(); nullable.ServerTimeout = new TimeSpan?(completeTransactionCommand.Timeout); nullable.TransactionId = completeTransactionCommand.TransactionId; Message message = this.transactionEnlistment.messageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpConnection/CompleteTransaction", completeTransactionCommand, nullable); WorkUnitInfo.AddTo(message.Headers, "TxnWorkUnit", completeTransactionCommand.TransactionId, this.transactionEnlistment.GetNextSequenceNumber()); IAsyncResult asyncResult = this.transactionEnlistment.channel.BeginRequest(message, SbmpProtocolDefaults.BufferTimeout(SbmpResourceManager.TransactionEnlistment.rollbackTimeout, this.transactionEnlistment.messageCreator.DisableClientOperationTimeBuffer), SbmpResourceManager.TransactionEnlistment.CompleteTransactionHelper.operationCallback, this); if (asyncResult.CompletedSynchronously) { this.OperationComplete(asyncResult); } } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception)) { throw; } this.OnError(exception); } }
protected override IEnumerator <IteratorAsyncResult <TIteratorAsyncResult> .AsyncStep> GetAsyncSteps() { if (this.Transaction == null) { this.wcfMessage = this.CreateWcfMessage(); } else { SbmpMessageCreator sbmpMessageCreator1 = (this.controlMessageCreator == null ? this.MessageCreator : this.controlMessageCreator.Value); SbmpTransactionalAsyncResult <TIteratorAsyncResult> sbmpTransactionalAsyncResult = this; IteratorAsyncResult <TIteratorAsyncResult> .BeginCall beginCall = (TIteratorAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => { SbmpResourceManager resourceManager = thisPtr.messagingFactory.ResourceManager; System.Transactions.Transaction transaction = thisPtr.Transaction; IRequestSessionChannel requestSessionChannel = thisPtr.channel; SbmpMessageCreator sbmpMessageCreator = sbmpMessageCreator1; object obj = thisPtr; return(resourceManager.BeginEnlist(transaction, requestSessionChannel, sbmpMessageCreator, new Action <RequestInfo>(obj.PartitionInfoSetter), t, c, s)); }; yield return(sbmpTransactionalAsyncResult.CallAsync(beginCall, (TIteratorAsyncResult thisPtr, IAsyncResult a) => thisPtr.txnSeqNumber = thisPtr.messagingFactory.ResourceManager.EndEnlist(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer)); this.wcfMessage = this.CreateWcfMessage(); WorkUnitInfo.AddTo(this.wcfMessage.Headers, "TxnWorkUnit", this.Transaction.TransactionInformation.LocalIdentifier, this.txnSeqNumber); } SbmpTransactionalAsyncResult <TIteratorAsyncResult> sbmpTransactionalAsyncResult1 = this; IteratorAsyncResult <TIteratorAsyncResult> .BeginCall beginCall1 = (TIteratorAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.channel.BeginRequest(thisPtr.wcfMessage, SbmpProtocolDefaults.BufferTimeout(t, this.messagingFactory.GetSettings().EnableAdditionalClientTimeout), c, s); yield return(sbmpTransactionalAsyncResult1.CallAsync(beginCall1, (TIteratorAsyncResult thisPtr, IAsyncResult a) => thisPtr.Response = thisPtr.channel.EndRequest(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer)); }