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;
///
///
/// [To be supplied.]
///
public class MessageQueueTransaction : IDisposable {
private ITransaction internalTransaction;
private MessageQueueTransactionStatus transactionStatus;
private bool disposed;
///
///
///
/// Creates a new Message Queuing internal transaction context.
///
///
public MessageQueueTransaction() {
this.transactionStatus = MessageQueueTransactionStatus.Initialized;
}
internal ITransaction InnerTransaction {
get {
return this.internalTransaction;
}
}
///
///
///
/// The status of the transaction that this object represents.
///
///
public MessageQueueTransactionStatus Status {
get {
return this.transactionStatus;
}
}
///
///
///
/// Rolls back the pending internal transaction.
///
///
public void Abort() {
lock (this) {
if (this.internalTransaction == null)
throw new InvalidOperationException(Res.GetString(Res.TransactionNotStarted));
else {
this.AbortInternalTransaction();
}
}
}
///
///
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;
}
///
///
///
/// Begins a new Message Queuing internal transaction context.
///
///
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;
}
}
}
///
///
internal ITransaction BeginQueueOperation() {
#pragma warning disable 0618
//@
Monitor.Enter(this);
#pragma warning restore 0618
return this.internalTransaction;
}
///
///
///
/// Commits a pending internal transaction.
///
///
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;
}
}
}
///
///
///
/// Disposes this transaction instance, if it is in a
/// pending status, the transaction will be aborted.
///
///
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
///
///
///
///
///
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
- AssertHelper.cs
- UndirectedGraph.cs
- ToolStripPanel.cs
- UriSection.cs
- Border.cs
- AssemblyInfo.cs
- AuthenticationModulesSection.cs
- NativeMethods.cs
- TypedRowHandler.cs
- DataObjectMethodAttribute.cs
- XsdBuildProvider.cs
- NetNamedPipeSecurity.cs
- GridViewCommandEventArgs.cs
- NavigationEventArgs.cs
- DrawingVisualDrawingContext.cs
- CollectionViewProxy.cs
- RemoteWebConfigurationHost.cs
- BaseServiceProvider.cs
- DeclaredTypeElementCollection.cs
- NetTcpSectionData.cs
- DbProviderServices.cs
- LinqDataSourceView.cs
- FileCodeGroup.cs
- ScrollBarRenderer.cs
- StateDesigner.Helpers.cs
- WhileDesigner.cs
- InlineUIContainer.cs
- PreProcessInputEventArgs.cs
- ErrorItem.cs
- RawStylusInput.cs
- SourceSwitch.cs
- AssemblyAttributesGoHere.cs
- ServiceContractAttribute.cs
- DataPagerCommandEventArgs.cs
- HMACMD5.cs
- XmlSchemaAppInfo.cs
- X509Utils.cs
- MetabaseSettings.cs
- EncryptedPackage.cs
- QueryConverter.cs
- HttpPostClientProtocol.cs
- BufferModeSettings.cs
- ClientSettingsStore.cs
- ParamArrayAttribute.cs
- ResourcesBuildProvider.cs
- WebUtil.cs
- DataGridViewColumnCollection.cs
- GZipDecoder.cs
- TryCatchDesigner.xaml.cs
- BufferModeSettings.cs
- While.cs
- SuppressIldasmAttribute.cs
- TdsParserStaticMethods.cs
- sortedlist.cs
- DataChangedEventManager.cs
- CodeChecksumPragma.cs
- SqlCacheDependencySection.cs
- PriorityChain.cs
- ObjectConverter.cs
- Attributes.cs
- DifferencingCollection.cs
- SplayTreeNode.cs
- AppDomainResourcePerfCounters.cs
- SymmetricAlgorithm.cs
- HostingEnvironmentSection.cs
- Crc32Helper.cs
- PasswordRecovery.cs
- HiddenFieldPageStatePersister.cs
- ProcessHost.cs
- DataSourceCache.cs
- ZipIOLocalFileBlock.cs
- UserControl.cs
- RuntimeArgumentHandle.cs
- TransactionManager.cs
- XmlCountingReader.cs
- Mapping.cs
- RowTypeElement.cs
- TabItemAutomationPeer.cs
- _TimerThread.cs
- ArcSegment.cs
- SignatureGenerator.cs
- MetafileEditor.cs
- DocumentCollection.cs
- _DomainName.cs
- BindingMemberInfo.cs
- Configuration.cs
- MouseActionValueSerializer.cs
- RuntimeConfigLKG.cs
- File.cs
- HttpMethodConstraint.cs
- ArraySubsetEnumerator.cs
- MobileControlBuilder.cs
- InnerItemCollectionView.cs
- EventRoute.cs
- FileClassifier.cs
- SchemaImporterExtensionElement.cs
- StylusPointPropertyInfo.cs
- ByteStream.cs
- UnsafeNativeMethods.cs
- DBAsyncResult.cs