Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Messaging / System / Messaging / MessageQueueTransaction.cs / 1305376 / MessageQueueTransaction.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging { using System.Threading; using System.Diagnostics; using System.Messaging.Interop; ////// /// public class MessageQueueTransaction : IDisposable { private ITransaction internalTransaction; private MessageQueueTransactionStatus transactionStatus; private bool disposed; ///[To be supplied.] ////// /// public MessageQueueTransaction() { this.transactionStatus = MessageQueueTransactionStatus.Initialized; } internal ITransaction InnerTransaction { get { return this.internalTransaction; } } ////// Creates a new Message Queuing internal transaction context. /// ////// /// public MessageQueueTransactionStatus Status { get { return this.transactionStatus; } } ////// The status of the transaction that this object represents. /// ////// /// public void Abort() { lock (this) { if (this.internalTransaction == null) throw new InvalidOperationException(Res.GetString(Res.TransactionNotStarted)); else { this.AbortInternalTransaction(); } } } ////// Rolls back the pending internal transaction. /// ////// private void AbortInternalTransaction() { int status = this.internalTransaction.Abort(0, 0, 0); if (MessageQueue.IsFatalError(status)) throw new MessageQueueException(status); this.internalTransaction = null; this.transactionStatus = MessageQueueTransactionStatus.Aborted; } /// /// /// public void Begin() { //Won't allow begining a new transaction after the object has been disposed. if (this.disposed) throw new ObjectDisposedException(GetType().Name); lock (this) { if (internalTransaction != null) throw new InvalidOperationException(Res.GetString(Res.TransactionStarted)); else { int status = SafeNativeMethods.MQBeginTransaction(out this.internalTransaction); if (MessageQueue.IsFatalError(status)) { this.internalTransaction = null; throw new MessageQueueException(status); } this.transactionStatus = MessageQueueTransactionStatus.Pending; } } } ////// Begins a new Message Queuing internal transaction context. /// ////// internal ITransaction BeginQueueOperation() { #pragma warning disable 0618 //@ Monitor.Enter(this); #pragma warning restore 0618 return this.internalTransaction; } /// /// /// public void Commit() { lock (this) { if (this.internalTransaction == null) throw new InvalidOperationException(Res.GetString(Res.TransactionNotStarted)); else { int status = this.internalTransaction.Commit(0, 0, 0); if (MessageQueue.IsFatalError(status)) throw new MessageQueueException(status); this.internalTransaction = null; this.transactionStatus = MessageQueueTransactionStatus.Committed; } } } ////// Commits a pending internal transaction. /// ////// /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ////// Disposes this transaction instance, if it is in a /// pending status, the transaction will be aborted. /// ////// /// protected virtual void Dispose(bool disposing) { if (disposing) { lock (this) { if (internalTransaction != null) this.AbortInternalTransaction(); } } this.disposed = true; } ////// ////// ~MessageQueueTransaction() { Dispose(false); } /// /// internal void EndQueueOperation() { Monitor.Exit(this); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging { using System.Threading; using System.Diagnostics; using System.Messaging.Interop; ////// /// public class MessageQueueTransaction : IDisposable { private ITransaction internalTransaction; private MessageQueueTransactionStatus transactionStatus; private bool disposed; ///[To be supplied.] ////// /// public MessageQueueTransaction() { this.transactionStatus = MessageQueueTransactionStatus.Initialized; } internal ITransaction InnerTransaction { get { return this.internalTransaction; } } ////// Creates a new Message Queuing internal transaction context. /// ////// /// public MessageQueueTransactionStatus Status { get { return this.transactionStatus; } } ////// The status of the transaction that this object represents. /// ////// /// public void Abort() { lock (this) { if (this.internalTransaction == null) throw new InvalidOperationException(Res.GetString(Res.TransactionNotStarted)); else { this.AbortInternalTransaction(); } } } ////// Rolls back the pending internal transaction. /// ////// private void AbortInternalTransaction() { int status = this.internalTransaction.Abort(0, 0, 0); if (MessageQueue.IsFatalError(status)) throw new MessageQueueException(status); this.internalTransaction = null; this.transactionStatus = MessageQueueTransactionStatus.Aborted; } /// /// /// public void Begin() { //Won't allow begining a new transaction after the object has been disposed. if (this.disposed) throw new ObjectDisposedException(GetType().Name); lock (this) { if (internalTransaction != null) throw new InvalidOperationException(Res.GetString(Res.TransactionStarted)); else { int status = SafeNativeMethods.MQBeginTransaction(out this.internalTransaction); if (MessageQueue.IsFatalError(status)) { this.internalTransaction = null; throw new MessageQueueException(status); } this.transactionStatus = MessageQueueTransactionStatus.Pending; } } } ////// Begins a new Message Queuing internal transaction context. /// ////// internal ITransaction BeginQueueOperation() { #pragma warning disable 0618 //@ Monitor.Enter(this); #pragma warning restore 0618 return this.internalTransaction; } /// /// /// public void Commit() { lock (this) { if (this.internalTransaction == null) throw new InvalidOperationException(Res.GetString(Res.TransactionNotStarted)); else { int status = this.internalTransaction.Commit(0, 0, 0); if (MessageQueue.IsFatalError(status)) throw new MessageQueueException(status); this.internalTransaction = null; this.transactionStatus = MessageQueueTransactionStatus.Committed; } } } ////// Commits a pending internal transaction. /// ////// /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ////// Disposes this transaction instance, if it is in a /// pending status, the transaction will be aborted. /// ////// /// protected virtual void Dispose(bool disposing) { if (disposing) { lock (this) { if (internalTransaction != null) this.AbortInternalTransaction(); } } this.disposed = true; } ////// ////// ~MessageQueueTransaction() { Dispose(false); } /// /// internal void EndQueueOperation() { Monitor.Exit(this); } } } // 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
- LeafCellTreeNode.cs
- WindowsFormsHelpers.cs
- SQLUtility.cs
- ContractBase.cs
- RemotingConfiguration.cs
- PerspectiveCamera.cs
- TextRangeBase.cs
- FieldNameLookup.cs
- AccessText.cs
- TextTreeRootNode.cs
- HMACSHA256.cs
- FormClosingEvent.cs
- XpsFilter.cs
- AvTraceDetails.cs
- BamlLocalizableResourceKey.cs
- EntityConnectionStringBuilder.cs
- KeyGestureValueSerializer.cs
- Mapping.cs
- TextElementCollectionHelper.cs
- SafeMILHandleMemoryPressure.cs
- WebPartVerbsEventArgs.cs
- BinaryFormatterWriter.cs
- GregorianCalendar.cs
- BitmapCodecInfo.cs
- BaseCodeDomTreeGenerator.cs
- CodeMethodReturnStatement.cs
- EndpointBehaviorElement.cs
- DataKeyArray.cs
- returneventsaver.cs
- AdCreatedEventArgs.cs
- ArrayElementGridEntry.cs
- AlgoModule.cs
- __FastResourceComparer.cs
- ExpressionServices.cs
- TransformationRules.cs
- SqlUnionizer.cs
- BindingExpressionBase.cs
- ClientApiGenerator.cs
- ClientBuildManagerCallback.cs
- WindowHideOrCloseTracker.cs
- CreateUserWizard.cs
- CustomWebEventKey.cs
- TreeViewBindingsEditor.cs
- XmlSignatureProperties.cs
- DSASignatureFormatter.cs
- OptimisticConcurrencyException.cs
- PersonalizationStateInfo.cs
- DeadCharTextComposition.cs
- ResXBuildProvider.cs
- NativeMethodsOther.cs
- TextProviderWrapper.cs
- AutoGeneratedFieldProperties.cs
- ProfilePropertyMetadata.cs
- RayMeshGeometry3DHitTestResult.cs
- ColorConverter.cs
- SignatureHelper.cs
- HitTestResult.cs
- RayMeshGeometry3DHitTestResult.cs
- RemotingAttributes.cs
- HtmlInputCheckBox.cs
- InternalRelationshipCollection.cs
- MailSettingsSection.cs
- StylusPointDescription.cs
- RoutedEventValueSerializer.cs
- SecurityTokenResolver.cs
- ElementProxy.cs
- ComponentEditorForm.cs
- WebPartConnectVerb.cs
- MetabaseServerConfig.cs
- ETagAttribute.cs
- SelectionEditor.cs
- MonikerSyntaxException.cs
- ListManagerBindingsCollection.cs
- UnmanagedHandle.cs
- StatusStrip.cs
- CaseExpr.cs
- QilExpression.cs
- ScriptResourceInfo.cs
- AssignDesigner.xaml.cs
- XsdCachingReader.cs
- LongValidatorAttribute.cs
- CollectionViewProxy.cs
- LinkArea.cs
- XmlExtensionFunction.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- VectorAnimation.cs
- SslStream.cs
- ListViewGroupConverter.cs
- SimpleType.cs
- SamlAction.cs
- SecurityHelper.cs
- HyperlinkAutomationPeer.cs
- Publisher.cs
- StringPropertyBuilder.cs
- unitconverter.cs
- HttpRequest.cs
- XamlDesignerSerializationManager.cs
- XhtmlBasicTextBoxAdapter.cs
- PatternMatcher.cs
- EllipticalNodeOperations.cs