// PushScope // // Push a transaction scope onto the stack. private void PushScope() { // Fixup the interop mode before we set current. if (!_interopModeSpecified) { // Transaction.InteropMode will take the interop mode on // for the scope in currentScope into account. _interopOption = Transaction.InteropMode(_savedCurrentScope); } // async function yield at await points and main thread can continue execution. We need to make sure the TLS data are restored appropriately. SaveTLSContextData(); if (AsyncFlowEnabled) { // Async Flow is enabled and CallContext will be used for ambient transaction. _threadContextData = CallContextCurrentData.CreateOrGetCurrentData(ContextKey); if (_savedCurrentScope == null && _savedCurrent == null) { // Clear TLS data so that transaction doesn't leak from current thread. ContextData.TLSCurrentData = null; } } else { // Legacy TransactionScope. Use TLS to track ambient transaction context. _threadContextData = ContextData.TLSCurrentData; CallContextCurrentData.ClearCurrentData(ContextKey, false); } // This call needs to be done first SetCurrent(_expectedCurrent); _threadContextData.CurrentScope = this; }
private void PushScope() { if (!this.interopModeSpecified) { this.interopOption = Transaction.InteropMode(this.savedCurrentScope); } this.SetCurrent(this.expectedCurrent); this.threadContextData.CurrentScope = this; }
// The validate method assumes that the existing parent ambient transaction scope is already looked up. private void ValidateAsyncFlowOptionAndESInteropOption() { if (AsyncFlowEnabled) { EnterpriseServicesInteropOption currentInteropOption = _interopOption; if (!_interopModeSpecified) { // Transaction.InteropMode will take the interop mode on // for the scope in currentScope into account. currentInteropOption = Transaction.InteropMode(_savedCurrentScope); } if (currentInteropOption != EnterpriseServicesInteropOption.None) { throw new NotSupportedException(SR.AsyncFlowAndESInteropNotSupported); } } }