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
- EditorZone.cs
- Buffer.cs
- Subtree.cs
- AsymmetricKeyExchangeFormatter.cs
- DataGridViewCell.cs
- ResetableIterator.cs
- MarkupExtensionReturnTypeAttribute.cs
- Win32Native.cs
- CommonObjectSecurity.cs
- BamlTreeMap.cs
- DynamicResourceExtension.cs
- DisplayInformation.cs
- ResolveDuplex11AsyncResult.cs
- LabelLiteral.cs
- SymmetricAlgorithm.cs
- Claim.cs
- FigureParaClient.cs
- HttpRawResponse.cs
- Material.cs
- DataList.cs
- GroupPartitionExpr.cs
- DuplicateWaitObjectException.cs
- Validator.cs
- MetaForeignKeyColumn.cs
- ContextMenuStrip.cs
- NegotiateStream.cs
- ConstraintManager.cs
- EncryptedKeyIdentifierClause.cs
- TraceContextRecord.cs
- XmlChildEnumerator.cs
- PlainXmlDeserializer.cs
- Rotation3D.cs
- IDReferencePropertyAttribute.cs
- XmlElement.cs
- StrokeCollectionDefaultValueFactory.cs
- Int32AnimationUsingKeyFrames.cs
- AssemblyAttributesGoHere.cs
- TaskResultSetter.cs
- ChannelSinkStacks.cs
- _UriSyntax.cs
- WebConfigurationHostFileChange.cs
- ThicknessAnimationBase.cs
- PnrpPermission.cs
- UTF8Encoding.cs
- HierarchicalDataSourceControl.cs
- PackWebRequestFactory.cs
- UrlMappingsModule.cs
- TemplateNameScope.cs
- HebrewNumber.cs
- StylusShape.cs
- BridgeDataReader.cs
- PostBackTrigger.cs
- PeerCollaborationPermission.cs
- NetMsmqSecurity.cs
- XhtmlBasicLabelAdapter.cs
- EmptyReadOnlyDictionaryInternal.cs
- WebServiceEnumData.cs
- MenuRendererStandards.cs
- ImageListStreamer.cs
- EnumerationRangeValidationUtil.cs
- PresentationTraceSources.cs
- DependencyObjectProvider.cs
- ToggleButton.cs
- NullableDecimalSumAggregationOperator.cs
- ConfigsHelper.cs
- DesignerForm.cs
- Mappings.cs
- DBBindings.cs
- ModifiableIteratorCollection.cs
- PackageProperties.cs
- DataObjectCopyingEventArgs.cs
- PtsHelper.cs
- DocumentSchemaValidator.cs
- LayoutDump.cs
- BindingExpression.cs
- Crc32.cs
- PropertyIDSet.cs
- Variant.cs
- InputLanguageEventArgs.cs
- Variable.cs
- COM2PropertyPageUITypeConverter.cs
- StylusPointPropertyId.cs
- CodeSnippetTypeMember.cs
- SplitterCancelEvent.cs
- CustomServiceCredentials.cs
- URI.cs
- filewebrequest.cs
- ProcessThread.cs
- RoleService.cs
- SchemaMapping.cs
- XD.cs
- Int32AnimationBase.cs
- DependencyPropertyKey.cs
- ToolStripPanelRenderEventArgs.cs
- ConfigurationConverterBase.cs
- DiscreteKeyFrames.cs
- VirtualPath.cs
- Pool.cs
- LazyTextWriterCreator.cs
- SqlProviderServices.cs