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
- ToolStrip.cs
- CssTextWriter.cs
- StackBuilderSink.cs
- SByte.cs
- ToolStripContentPanelRenderEventArgs.cs
- UrlPropertyAttribute.cs
- StructuralType.cs
- StructuredCompositeActivityDesigner.cs
- DataGridSortCommandEventArgs.cs
- ConstantCheck.cs
- WebDescriptionAttribute.cs
- MLangCodePageEncoding.cs
- DataTemplateKey.cs
- SendingRequestEventArgs.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- TextEditorMouse.cs
- RootAction.cs
- TargetConverter.cs
- Compiler.cs
- XmlUtil.cs
- MLangCodePageEncoding.cs
- SqlPersonalizationProvider.cs
- hwndwrapper.cs
- HttpApplicationFactory.cs
- DataServiceHostFactory.cs
- OleDbWrapper.cs
- FlowchartDesignerCommands.cs
- DynamicMetaObject.cs
- Hex.cs
- WebPartConnectionCollection.cs
- FixedDocumentSequencePaginator.cs
- MsmqOutputChannel.cs
- FilteredAttributeCollection.cs
- ArgumentOutOfRangeException.cs
- PropertyStore.cs
- SatelliteContractVersionAttribute.cs
- FileLogRecordHeader.cs
- ColorTransformHelper.cs
- DataGridCell.cs
- FieldDescriptor.cs
- HttpProtocolReflector.cs
- FileUtil.cs
- SqlComparer.cs
- cookie.cs
- GenericWebPart.cs
- DbResourceAllocator.cs
- XPathScanner.cs
- HashCodeCombiner.cs
- FormViewCommandEventArgs.cs
- MetadataItemCollectionFactory.cs
- GiveFeedbackEvent.cs
- DeclarativeCatalogPart.cs
- Point3DCollectionConverter.cs
- ProgressPage.cs
- RichTextBox.cs
- TextSerializer.cs
- TypeValidationEventArgs.cs
- DefaultValidator.cs
- ScriptResourceHandler.cs
- TextBreakpoint.cs
- GcHandle.cs
- ObjectDataSourceDisposingEventArgs.cs
- TextViewSelectionProcessor.cs
- MenuRendererStandards.cs
- DataGridViewAccessibleObject.cs
- RouteValueExpressionBuilder.cs
- ConfigDefinitionUpdates.cs
- Models.cs
- ping.cs
- XamlFigureLengthSerializer.cs
- ByteStream.cs
- LicenseContext.cs
- SpecialFolderEnumConverter.cs
- CheckedPointers.cs
- OleDbRowUpdatingEvent.cs
- PersianCalendar.cs
- ListViewContainer.cs
- NetworkInformationException.cs
- OdbcConnectionHandle.cs
- DataControlImageButton.cs
- X509ThumbprintKeyIdentifierClause.cs
- SimpleRecyclingCache.cs
- HighlightVisual.cs
- ParameterBuilder.cs
- ScalarRestriction.cs
- SecurityContextTokenCache.cs
- UIElement3DAutomationPeer.cs
- PromptEventArgs.cs
- HtmlTable.cs
- ActivityUtilities.cs
- DefaultBindingPropertyAttribute.cs
- WinEventTracker.cs
- ResolveMatches11.cs
- OleDbPermission.cs
- FontCollection.cs
- TextEditorLists.cs
- StyleBamlTreeBuilder.cs
- Point.cs
- BamlBinaryReader.cs
- TrustManagerPromptUI.cs