Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities.DurableInstancing / System / Activities / DurableInstancing / InstanceLockTracking.cs / 1305376 / InstanceLockTracking.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.DurableInstancing { using System.Runtime.DurableInstancing; using System.Transactions; sealed class InstanceLockTracking { object synchLock; SqlWorkflowInstanceStore store; public InstanceLockTracking(SqlWorkflowInstanceStore store) { this.InstanceId = Guid.Empty; this.store = store; this.synchLock = new object(); } public Guid InstanceId { get; set; } public bool BoundToLock { get; set; } public long InstanceVersion { get; set; } public bool IsHandleFreed { get; set; } public bool IsSafeToUnlock { get; set; } public void HandleFreed() { lock (this.synchLock) { if (this.BoundToLock && this.IsSafeToUnlock) { this.store.GenerateUnlockCommand(this); } this.IsHandleFreed = true; } } public void TrackStoreLock(Guid instanceId, long instanceVersion, DependentTransaction dependentTransaction) { this.BoundToLock = true; this.InstanceId = instanceId; this.InstanceVersion = instanceVersion; if (dependentTransaction != null) { dependentTransaction.TransactionCompleted += new TransactionCompletedEventHandler(TransactionCompleted); } else { this.IsSafeToUnlock = true; } } public void TrackStoreUnlock(DependentTransaction dependentTransaction) { this.BoundToLock = false; this.IsHandleFreed = true; if (dependentTransaction != null) { dependentTransaction.TransactionCompleted += new TransactionCompletedEventHandler(TransactedUnlockCompleted); } } void TransactionCompleted(object sender, TransactionEventArgs e) { lock (this.synchLock) { if (e.Transaction.TransactionInformation.Status == TransactionStatus.Committed) { if (this.IsHandleFreed) { this.store.GenerateUnlockCommand(this); } else { this.IsSafeToUnlock = true; } } else { this.BoundToLock = false; } } } void TransactedUnlockCompleted(object sender, TransactionEventArgs e) { lock (this.synchLock) { if (e.Transaction.TransactionInformation.Status != TransactionStatus.Committed && this.IsSafeToUnlock) { this.store.GenerateUnlockCommand(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
- WhitespaceSignificantCollectionAttribute.cs
- Part.cs
- Funcletizer.cs
- VoiceSynthesis.cs
- SqlClientWrapperSmiStream.cs
- FontStyles.cs
- NetPeerTcpBindingElement.cs
- LazyTextWriterCreator.cs
- HealthMonitoringSectionHelper.cs
- PathGradientBrush.cs
- ReferencedCategoriesDocument.cs
- SimpleMailWebEventProvider.cs
- ActivityXamlServices.cs
- WsdlInspector.cs
- Validator.cs
- UriTemplateVariablePathSegment.cs
- TransactionFormatter.cs
- SoapExtension.cs
- RegisterResponseInfo.cs
- DataExpression.cs
- DataViewSetting.cs
- DbSetClause.cs
- SystemUnicastIPAddressInformation.cs
- NavigationWindow.cs
- ComponentResourceKey.cs
- WebBrowserNavigatedEventHandler.cs
- DynamicQueryStringParameter.cs
- File.cs
- SynchronizedDisposablePool.cs
- CharConverter.cs
- BinaryWriter.cs
- PackagePartCollection.cs
- SHA1CryptoServiceProvider.cs
- Expressions.cs
- XmlBinaryWriter.cs
- handlecollector.cs
- NavigationWindow.cs
- FileEnumerator.cs
- TextDecorationCollectionConverter.cs
- BasePropertyDescriptor.cs
- FloatUtil.cs
- Root.cs
- BamlVersionHeader.cs
- SqlError.cs
- RawStylusActions.cs
- SystemInfo.cs
- DataGridViewRowHeaderCell.cs
- XamlVector3DCollectionSerializer.cs
- FramingDecoders.cs
- ParameterToken.cs
- ConfigViewGenerator.cs
- EntityContainerAssociationSet.cs
- VisualTarget.cs
- ObjectDataSource.cs
- NavigationWindowAutomationPeer.cs
- DatatypeImplementation.cs
- OdbcConnectionHandle.cs
- FtpCachePolicyElement.cs
- CallbackWrapper.cs
- AppSecurityManager.cs
- X509KeyIdentifierClauseType.cs
- MimeMultiPart.cs
- QilInvokeLateBound.cs
- XPathNodeIterator.cs
- FragmentNavigationEventArgs.cs
- StringAnimationUsingKeyFrames.cs
- OperationResponse.cs
- NTAccount.cs
- WebPartConnectionsConnectVerb.cs
- FilterEventArgs.cs
- JavaScriptString.cs
- OverflowException.cs
- Assert.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- SqlDependencyUtils.cs
- TouchesCapturedWithinProperty.cs
- PixelFormats.cs
- KnownTypesProvider.cs
- WebPartUtil.cs
- ContractType.cs
- ExceptionTranslationTable.cs
- DecoderExceptionFallback.cs
- XmlSerializableWriter.cs
- LZCodec.cs
- XmlSchemas.cs
- HelloMessageApril2005.cs
- Padding.cs
- TabRenderer.cs
- DataGridViewDataConnection.cs
- Int64.cs
- MemberProjectedSlot.cs
- IODescriptionAttribute.cs
- XmlValueConverter.cs
- MenuItemStyle.cs
- FreezableOperations.cs
- X509Extension.cs
- ItemChangedEventArgs.cs
- SizeF.cs
- AttachmentCollection.cs
- HttpHandlerAction.cs