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
- SiteMapProvider.cs
- input.cs
- LocalIdKeyIdentifierClause.cs
- Attributes.cs
- SqlDataSourceConfigureSelectPanel.cs
- SurrogateChar.cs
- TraceInternal.cs
- FilterableAttribute.cs
- ProgressBarAutomationPeer.cs
- SqlBooleanMismatchVisitor.cs
- ItemCollection.cs
- MobileControlsSection.cs
- HttpFileCollectionWrapper.cs
- WpfGeneratedKnownProperties.cs
- DynamicDocumentPaginator.cs
- ContentElement.cs
- HideDisabledControlAdapter.cs
- AttachmentService.cs
- EdmTypeAttribute.cs
- ConstrainedGroup.cs
- SpeakProgressEventArgs.cs
- XmlReflectionMember.cs
- FieldNameLookup.cs
- UrlPropertyAttribute.cs
- ThrowHelper.cs
- DataControlReference.cs
- ApplicationServicesHostFactory.cs
- ParameterModifier.cs
- DataRelation.cs
- ConnectionsZone.cs
- GACMembershipCondition.cs
- RowUpdatingEventArgs.cs
- ContextMenuAutomationPeer.cs
- DBPropSet.cs
- DataGridViewCellStyleEditor.cs
- EdmScalarPropertyAttribute.cs
- WebDisplayNameAttribute.cs
- DataListDesigner.cs
- ObservableCollection.cs
- PathFigureCollection.cs
- DecoderNLS.cs
- ExpressionNormalizer.cs
- DateTimeConverter.cs
- HiddenField.cs
- IISMapPath.cs
- AppModelKnownContentFactory.cs
- ObjectConverter.cs
- BlobPersonalizationState.cs
- UshortList2.cs
- InfoCardClaimCollection.cs
- ProxyWebPart.cs
- DocumentViewerBaseAutomationPeer.cs
- MetadataFile.cs
- IisTraceWebEventProvider.cs
- selecteditemcollection.cs
- Bold.cs
- MasterPageBuildProvider.cs
- DomNameTable.cs
- DiscoveryDocumentReference.cs
- XmlDigitalSignatureProcessor.cs
- RedBlackList.cs
- HeaderUtility.cs
- ApplicationActivator.cs
- selecteditemcollection.cs
- SafeLibraryHandle.cs
- PolicyDesigner.cs
- BoundColumn.cs
- ItemAutomationPeer.cs
- PrimaryKeyTypeConverter.cs
- XmlSignatureProperties.cs
- CurrentChangingEventManager.cs
- DataControlFieldCell.cs
- DbReferenceCollection.cs
- StatusBarAutomationPeer.cs
- TimelineGroup.cs
- RegularExpressionValidator.cs
- ProfileSettings.cs
- Canonicalizers.cs
- BlurEffect.cs
- XmlIncludeAttribute.cs
- IncrementalReadDecoders.cs
- SweepDirectionValidation.cs
- HttpListener.cs
- CodeObject.cs
- UnsafeNativeMethods.cs
- ItemType.cs
- StringStorage.cs
- Misc.cs
- EditorResources.cs
- MasterPageParser.cs
- FloatUtil.cs
- SamlAdvice.cs
- WsiProfilesElement.cs
- SortQuery.cs
- DataServiceHost.cs
- TextTreeTextBlock.cs
- LogLogRecord.cs
- XamlSerializerUtil.cs
- TypeConverterValueSerializer.cs
- FeatureManager.cs