Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StoreAnnotationsMap.cs
- MetadataArtifactLoaderResource.cs
- EnglishPluralizationService.cs
- ExpressionBuilderContext.cs
- UpdatePanelTriggerCollection.cs
- ListBoxItem.cs
- ShowExpandedMultiValueConverter.cs
- HtmlWindowCollection.cs
- EntityTypeBase.cs
- MemberExpression.cs
- BamlLocalizer.cs
- SqlRecordBuffer.cs
- Facet.cs
- UpdateManifestForBrowserApplication.cs
- CleanUpVirtualizedItemEventArgs.cs
- HwndAppCommandInputProvider.cs
- ExceptionUtil.cs
- CommandBinding.cs
- ConfigurationProperty.cs
- FileFormatException.cs
- DaylightTime.cs
- CapabilitiesPattern.cs
- CompensatableTransactionScopeActivity.cs
- ConnectionPoolRegistry.cs
- FontWeights.cs
- PolyLineSegmentFigureLogic.cs
- MouseEvent.cs
- ColorPalette.cs
- Clipboard.cs
- AppModelKnownContentFactory.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- SiteMapSection.cs
- TransformValueSerializer.cs
- Group.cs
- FieldNameLookup.cs
- IndexedEnumerable.cs
- LassoHelper.cs
- TabletDevice.cs
- DesignerDataConnection.cs
- DefaultHttpHandler.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- WizardPanel.cs
- DropDownButton.cs
- OneOfElement.cs
- PowerStatus.cs
- WindowsListView.cs
- BitmapEffectInput.cs
- XmlDataSource.cs
- AutomationProperty.cs
- SqlError.cs
- SqlDependency.cs
- WindowsFormsHostAutomationPeer.cs
- FakeModelPropertyImpl.cs
- UrlPropertyAttribute.cs
- WizardForm.cs
- WebPartTransformerCollection.cs
- CorrelationResolver.cs
- DbConnectionHelper.cs
- DataSysAttribute.cs
- CollectionBase.cs
- Hashtable.cs
- CheckableControlBaseAdapter.cs
- ConstructorNeedsTagAttribute.cs
- InputScopeManager.cs
- XmlSiteMapProvider.cs
- InteropAutomationProvider.cs
- MeasurementDCInfo.cs
- RangeBase.cs
- MetadataExchangeBindings.cs
- DataGridView.cs
- XpsViewerException.cs
- HwndMouseInputProvider.cs
- RealProxy.cs
- EncoderBestFitFallback.cs
- MediaElementAutomationPeer.cs
- FormatControl.cs
- PointCollection.cs
- ModuleElement.cs
- SchemaName.cs
- SwitchDesigner.xaml.cs
- DynamicResourceExtension.cs
- SecureEnvironment.cs
- XslAstAnalyzer.cs
- TypeUsage.cs
- SubqueryRules.cs
- XamlInterfaces.cs
- Message.cs
- SafeNativeMethods.cs
- FieldNameLookup.cs
- UrlMappingsModule.cs
- XPathNavigatorKeyComparer.cs
- MultipartIdentifier.cs
- OdbcConnectionStringbuilder.cs
- StreamGeometry.cs
- BuildProvider.cs
- HttpRawResponse.cs
- KnownIds.cs
- WebDisplayNameAttribute.cs
- FontDifferentiator.cs
- PropertyGridCommands.cs