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
- MachineKey.cs
- Scheduling.cs
- ReceiveMessageAndVerifySecurityAsyncResultBase.cs
- EncoderExceptionFallback.cs
- OracleTransaction.cs
- COM2ColorConverter.cs
- MultiByteCodec.cs
- WithStatement.cs
- SelectionEditingBehavior.cs
- Delegate.cs
- filewebresponse.cs
- XmlDocument.cs
- DocumentViewerBaseAutomationPeer.cs
- ApplicationException.cs
- TrustManagerMoreInformation.cs
- HttpResponseInternalBase.cs
- DependencyPropertyAttribute.cs
- ExceptionList.cs
- GotoExpression.cs
- HtmlEncodedRawTextWriter.cs
- SoapEnumAttribute.cs
- DoubleMinMaxAggregationOperator.cs
- ProtocolsConfigurationEntry.cs
- AppLevelCompilationSectionCache.cs
- OperationContractAttribute.cs
- TreeViewCancelEvent.cs
- ProcessModuleCollection.cs
- DataRecordInfo.cs
- DataSourceDescriptorCollection.cs
- UrlAuthFailureHandler.cs
- WinFormsSpinner.cs
- AddInServer.cs
- WpfXamlMember.cs
- BuildDependencySet.cs
- HandlerWithFactory.cs
- IncomingWebRequestContext.cs
- Path.cs
- FontNameEditor.cs
- GenericRootAutomationPeer.cs
- NetMsmqBindingElement.cs
- arc.cs
- SevenBitStream.cs
- FactoryMaker.cs
- ByteKeyFrameCollection.cs
- GeometryDrawing.cs
- GradientSpreadMethodValidation.cs
- ResourceSetExpression.cs
- InputElement.cs
- CodeVariableDeclarationStatement.cs
- StackOverflowException.cs
- Size3D.cs
- CopyOnWriteList.cs
- WebBrowser.cs
- KnownBoxes.cs
- RelationHandler.cs
- SqlReorderer.cs
- ExpandCollapseProviderWrapper.cs
- AppSettingsSection.cs
- UnsafeNativeMethods.cs
- ConfigsHelper.cs
- RawTextInputReport.cs
- SkewTransform.cs
- XPathDocumentNavigator.cs
- ObjRef.cs
- SystemResourceKey.cs
- SafeRightsManagementQueryHandle.cs
- TargetFrameworkAttribute.cs
- CompatibleComparer.cs
- XPathPatternParser.cs
- ScrollProperties.cs
- PathStreamGeometryContext.cs
- SqlCacheDependencySection.cs
- TextSpan.cs
- CurrencyWrapper.cs
- UpDownEvent.cs
- AnimationStorage.cs
- XPathNodeInfoAtom.cs
- NCryptNative.cs
- IndexerNameAttribute.cs
- RectValueSerializer.cs
- coordinatorscratchpad.cs
- BinaryMethodMessage.cs
- GenericEnumerator.cs
- DbProviderSpecificTypePropertyAttribute.cs
- RowVisual.cs
- MatrixCamera.cs
- MemberHolder.cs
- XmlUtf8RawTextWriter.cs
- WebHttpDispatchOperationSelectorData.cs
- PerfService.cs
- TextServicesCompartmentEventSink.cs
- ExternalFile.cs
- IntSecurity.cs
- EditBehavior.cs
- DataTrigger.cs
- EntityClientCacheKey.cs
- ObjectList.cs
- ScriptingWebServicesSectionGroup.cs
- ObjectToModelValueConverter.cs
- DataRecordInternal.cs