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
- ReaderWriterLockWrapper.cs
- PropertyBuilder.cs
- HTMLTagNameToTypeMapper.cs
- FileUtil.cs
- AsyncStreamReader.cs
- DefinitionUpdate.cs
- MultiDataTrigger.cs
- IndentedTextWriter.cs
- PocoPropertyAccessorStrategy.cs
- PrimitiveType.cs
- CapacityStreamGeometryContext.cs
- DeliveryRequirementsAttribute.cs
- WpfSharedXamlSchemaContext.cs
- SchemaImporter.cs
- FieldNameLookup.cs
- XmlSchemaImport.cs
- TreeView.cs
- DynamicObject.cs
- DataSourceSelectArguments.cs
- PasswordRecovery.cs
- ColumnMap.cs
- StateMachineAction.cs
- MetaTable.cs
- XmlSerializationGeneratedCode.cs
- PageParser.cs
- DefaultEventAttribute.cs
- ReliableChannelListener.cs
- MarkupCompilePass2.cs
- TabPanel.cs
- MembershipUser.cs
- Clock.cs
- ResourceManager.cs
- WebResourceUtil.cs
- Latin1Encoding.cs
- WebZone.cs
- DesignerAttribute.cs
- LogConverter.cs
- Rfc2898DeriveBytes.cs
- ControlAdapter.cs
- LinkLabelLinkClickedEvent.cs
- TextLine.cs
- RoleService.cs
- SecUtil.cs
- RegexInterpreter.cs
- ReflectionUtil.cs
- ImageButton.cs
- BitmapFrameDecode.cs
- Faults.cs
- HttpSessionStateBase.cs
- Baml6Assembly.cs
- BitmapInitialize.cs
- PageBuildProvider.cs
- DeferredReference.cs
- FlowDocumentScrollViewer.cs
- WindowsRichEditRange.cs
- StorageSetMapping.cs
- ExpressionBuilderContext.cs
- XmlSerializationGeneratedCode.cs
- ArcSegment.cs
- ComPlusSynchronizationContext.cs
- CriticalHandle.cs
- TypeHelpers.cs
- LockCookie.cs
- FixedTextSelectionProcessor.cs
- ObjectDataSourceEventArgs.cs
- RadioButtonStandardAdapter.cs
- MetadataArtifactLoaderComposite.cs
- SimpleRecyclingCache.cs
- ConfigurationSectionHelper.cs
- ValueHandle.cs
- MessagePartProtectionMode.cs
- ProgressPage.cs
- CqlParser.cs
- HtmlInputReset.cs
- SqlDataSourceCommandEventArgs.cs
- CurrentChangedEventManager.cs
- GreaterThan.cs
- HtmlEncodedRawTextWriter.cs
- figurelengthconverter.cs
- unitconverter.cs
- BamlResourceContent.cs
- Pair.cs
- UpdateExpressionVisitor.cs
- RootProfilePropertySettingsCollection.cs
- DbException.cs
- BinarySecretKeyIdentifierClause.cs
- InstancePersistenceContext.cs
- LineServices.cs
- ContractInstanceProvider.cs
- DtrList.cs
- UIElement.cs
- InvalidateEvent.cs
- CoreSwitches.cs
- GridItemCollection.cs
- DataGridCellInfo.cs
- DefaultObjectMappingItemCollection.cs
- MissingFieldException.cs
- AxisAngleRotation3D.cs
- ToolStripTextBox.cs
- linebase.cs