Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / WorkflowPersistenceContext.cs / 1305376 / WorkflowPersistenceContext.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities { using System.Collections.Generic; using System.Transactions; using System.Runtime; class WorkflowPersistenceContext { CommittableTransaction contextOwnedTransaction; Transaction clonedTransaction; public WorkflowPersistenceContext(bool transactionRequired, TimeSpan transactionTimeout) : this(transactionRequired, CloneAmbientTransaction(), transactionTimeout) { } public WorkflowPersistenceContext(bool transactionRequired, Transaction transactionToUse, TimeSpan transactionTimeout) { if (transactionToUse != null) { this.clonedTransaction = transactionToUse; } else if (transactionRequired) { this.contextOwnedTransaction = new CommittableTransaction(transactionTimeout); // Clone it so that we don't pass a CommittableTransaction to the participants this.clonedTransaction = this.contextOwnedTransaction.Clone(); } } public Transaction PublicTransaction { get { return this.clonedTransaction; } } public void Abort() { if (this.contextOwnedTransaction != null) { try { this.contextOwnedTransaction.Rollback(); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } // ---- these exceptions as we are already on the error path } } } public void Complete() { if (this.contextOwnedTransaction != null) { this.contextOwnedTransaction.Commit(); } } // Returns true if end needs to be called // Note: this is side effecting even if it returns false public bool TryBeginComplete(AsyncCallback callback, object state, out IAsyncResult result) { // In the interest of allocating less objects we don't implement // the full async pattern here. Instead, we've flattened it to // do the [....] part and then optionally delegate down to the inner // BeginCommit. if (this.contextOwnedTransaction != null) { result = this.contextOwnedTransaction.BeginCommit(callback, state); return true; } else { result = null; return false; } } public void EndComplete(IAsyncResult result) { Fx.Assert(this.contextOwnedTransaction != null, "We must have a contextOwnedTransaction if we are calling End"); this.contextOwnedTransaction.EndCommit(result); } // We might as well clone the ambient transaction so that PersistenceParticipants // can't cast to a CommittableTransaction. static Transaction CloneAmbientTransaction() { Transaction ambientTransaction = Transaction.Current; return ambientTransaction == null ? null : ambientTransaction.Clone(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataServiceHostWrapper.cs
- HtmlInputReset.cs
- AssemblyAttributes.cs
- Int32AnimationBase.cs
- HierarchicalDataSourceControl.cs
- Gdiplus.cs
- PrivilegedConfigurationManager.cs
- CursorConverter.cs
- XmlTextReader.cs
- CompositionAdorner.cs
- MemberRestriction.cs
- UpDownBase.cs
- coordinatorfactory.cs
- CachedBitmap.cs
- ButtonPopupAdapter.cs
- CompiledQueryCacheEntry.cs
- TypeReference.cs
- ExportException.cs
- SHA384Managed.cs
- BodyWriter.cs
- NamedPermissionSet.cs
- TypeLibConverter.cs
- CTreeGenerator.cs
- WebPartCancelEventArgs.cs
- SvcMapFileLoader.cs
- ParallelQuery.cs
- SoapConverter.cs
- ArrayEditor.cs
- ResourceType.cs
- Line.cs
- IndependentAnimationStorage.cs
- RectangleGeometry.cs
- XmlElement.cs
- ObjectQueryState.cs
- SocketElement.cs
- TimeoutValidationAttribute.cs
- FunctionUpdateCommand.cs
- MediaElementAutomationPeer.cs
- MimeMultiPart.cs
- MatrixCamera.cs
- Inline.cs
- TextEditorDragDrop.cs
- ProviderSettings.cs
- SystemWebSectionGroup.cs
- DesignTimeVisibleAttribute.cs
- StackBuilderSink.cs
- exports.cs
- FormViewDeleteEventArgs.cs
- RadialGradientBrush.cs
- FtpWebResponse.cs
- Empty.cs
- CommandConverter.cs
- CopyAttributesAction.cs
- ColorComboBox.cs
- _TLSstream.cs
- uribuilder.cs
- BitmapEffectInput.cs
- ImageKeyConverter.cs
- MsmqInputMessagePool.cs
- EmbossBitmapEffect.cs
- Aggregates.cs
- XmlMembersMapping.cs
- DataGridTextBoxColumn.cs
- QilPatternFactory.cs
- SimpleColumnProvider.cs
- ContextMenuAutomationPeer.cs
- Message.cs
- NativeCppClassAttribute.cs
- AppDomain.cs
- ErrorFormatter.cs
- ScopeElementCollection.cs
- FunctionImportMapping.cs
- ObservableCollection.cs
- WindowsUserNameCachingSecurityTokenAuthenticator.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- NumberFormatInfo.cs
- MapPathBasedVirtualPathProvider.cs
- ValidationRule.cs
- DrawingContextWalker.cs
- FilterElement.cs
- PublisherMembershipCondition.cs
- Rect3DConverter.cs
- ItemTypeToolStripMenuItem.cs
- SeekStoryboard.cs
- MobileTemplatedControlDesigner.cs
- WebPartTransformerAttribute.cs
- CodeThrowExceptionStatement.cs
- ErrorHandlingReceiver.cs
- Errors.cs
- SecurityHelper.cs
- ConstructorBuilder.cs
- Variant.cs
- TimeEnumHelper.cs
- ConsoleCancelEventArgs.cs
- _RequestCacheProtocol.cs
- ManagedWndProcTracker.cs
- GrammarBuilderBase.cs
- RIPEMD160.cs
- DrawToolTipEventArgs.cs
- MethodRental.cs