Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / RunTime / Hosting / WorkflowTransactionService.cs / 1305376 / WorkflowTransactionService.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- #region Using directives using System; using System.Transactions; #endregion namespace System.Workflow.Runtime.Hosting { public abstract class WorkflowCommitWorkBatchService : WorkflowRuntimeService { public delegate void CommitWorkBatchCallback(); virtual internal protected void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) { Transaction tx = null; if (null == Transaction.Current) tx = new CommittableTransaction(); else tx = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete); try { using (TransactionScope ts = new TransactionScope(tx)) { commitWorkBatchCallback(); ts.Complete(); } CommittableTransaction committableTransaction = tx as CommittableTransaction; if (committableTransaction != null) committableTransaction.Commit(); DependentTransaction dependentTransaction = tx as DependentTransaction; if (dependentTransaction != null) dependentTransaction.Complete(); } catch (Exception e) { tx.Rollback(e); throw; } finally { if (tx != null) { tx.Dispose(); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- #region Using directives using System; using System.Transactions; #endregion namespace System.Workflow.Runtime.Hosting { public abstract class WorkflowCommitWorkBatchService : WorkflowRuntimeService { public delegate void CommitWorkBatchCallback(); virtual internal protected void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) { Transaction tx = null; if (null == Transaction.Current) tx = new CommittableTransaction(); else tx = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete); try { using (TransactionScope ts = new TransactionScope(tx)) { commitWorkBatchCallback(); ts.Complete(); } CommittableTransaction committableTransaction = tx as CommittableTransaction; if (committableTransaction != null) committableTransaction.Commit(); DependentTransaction dependentTransaction = tx as DependentTransaction; if (dependentTransaction != null) dependentTransaction.Complete(); } catch (Exception e) { tx.Rollback(e); throw; } finally { if (tx != null) { tx.Dispose(); } } } } } // 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
- ColorKeyFrameCollection.cs
- ToolZoneDesigner.cs
- PageEventArgs.cs
- XmlWrappingReader.cs
- XmlComplianceUtil.cs
- ScopelessEnumAttribute.cs
- RoleService.cs
- GlyphRunDrawing.cs
- ValidatingReaderNodeData.cs
- ImageIndexConverter.cs
- SessionStateItemCollection.cs
- OperandQuery.cs
- MultiPropertyDescriptorGridEntry.cs
- InputDevice.cs
- DataGridLength.cs
- SqlInternalConnection.cs
- ValidationSummaryDesigner.cs
- Match.cs
- FormClosingEvent.cs
- EventListenerClientSide.cs
- VScrollBar.cs
- Polygon.cs
- ModelItemDictionary.cs
- BamlBinaryReader.cs
- ProfileSection.cs
- EditorPartChrome.cs
- GorillaCodec.cs
- selecteditemcollection.cs
- ParentQuery.cs
- LambdaExpression.cs
- TreeViewItem.cs
- PolicyStatement.cs
- PrintDialog.cs
- WindowsListBox.cs
- BeginSelectCardRequest.cs
- MsmqNonTransactedPoisonHandler.cs
- MouseEvent.cs
- SqlInternalConnectionTds.cs
- TextElementEnumerator.cs
- DbExpressionBuilder.cs
- XamlPoint3DCollectionSerializer.cs
- CanonicalFontFamilyReference.cs
- TemplatedAdorner.cs
- AttachmentCollection.cs
- ListenerElementsCollection.cs
- LogExtentCollection.cs
- ProfileInfo.cs
- WindowHideOrCloseTracker.cs
- XsdValidatingReader.cs
- PagesSection.cs
- GridEntry.cs
- Cursor.cs
- Translator.cs
- HtmlTitle.cs
- NativeMethods.cs
- EventEntry.cs
- WebPartMinimizeVerb.cs
- GridItemProviderWrapper.cs
- XmlSerializerAssemblyAttribute.cs
- Crc32.cs
- DEREncoding.cs
- TargetControlTypeCache.cs
- SafeSystemMetrics.cs
- unitconverter.cs
- ConvertTextFrag.cs
- CheckedListBox.cs
- ChannelCacheSettings.cs
- ClientBuildManagerCallback.cs
- DispatcherTimer.cs
- FontFamilyValueSerializer.cs
- MachineKeySection.cs
- NativeMethods.cs
- DesignerTextViewAdapter.cs
- Perspective.cs
- AssociativeAggregationOperator.cs
- WebControlAdapter.cs
- SqlNodeAnnotations.cs
- TextEditorThreadLocalStore.cs
- NoResizeHandleGlyph.cs
- EncoderParameter.cs
- RijndaelManagedTransform.cs
- XmlSchemaSimpleType.cs
- CodeMemberField.cs
- StringUtil.cs
- DoubleLink.cs
- ConstrainedDataObject.cs
- WorkflowRuntime.cs
- UInt32Storage.cs
- ConnectionStringSettingsCollection.cs
- DefaultBinder.cs
- OrderingQueryOperator.cs
- CollectionChangeEventArgs.cs
- RectAnimation.cs
- SettingsPropertyWrongTypeException.cs
- PropertyInfo.cs
- Underline.cs
- MustUnderstandSoapException.cs
- PerformanceCounterPermission.cs
- ImageSourceConverter.cs
- InternalConfigEventArgs.cs