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
- WpfGeneratedKnownProperties.cs
- DetailsViewCommandEventArgs.cs
- SqlInternalConnectionSmi.cs
- FullTextLine.cs
- RegisteredExpandoAttribute.cs
- Misc.cs
- LogWriteRestartAreaState.cs
- TextServicesCompartment.cs
- GridViewRowEventArgs.cs
- String.cs
- FormViewModeEventArgs.cs
- NetTcpSecurityElement.cs
- HttpCachePolicy.cs
- ExceptionUtil.cs
- DataColumnPropertyDescriptor.cs
- SQLBinary.cs
- Int32CollectionConverter.cs
- Suspend.cs
- XmlElement.cs
- SpellerError.cs
- NavigationWindowAutomationPeer.cs
- DefaultSection.cs
- BuiltInExpr.cs
- TreeViewImageIndexConverter.cs
- behaviorssection.cs
- XmlILModule.cs
- MappingSource.cs
- ClientTarget.cs
- HwndMouseInputProvider.cs
- RegistrySecurity.cs
- PrePostDescendentsWalker.cs
- X509ChainPolicy.cs
- InkCanvas.cs
- BindingList.cs
- ControlUtil.cs
- HijriCalendar.cs
- CommandEventArgs.cs
- SerialReceived.cs
- Schema.cs
- GenericEnumerator.cs
- CompilerResults.cs
- FamilyMap.cs
- FontCacheUtil.cs
- TimelineGroup.cs
- ProcessHost.cs
- DataGridLengthConverter.cs
- OrthographicCamera.cs
- ScrollViewer.cs
- Message.cs
- NameValueConfigurationElement.cs
- EnumerableRowCollectionExtensions.cs
- TypeGeneratedEventArgs.cs
- UpdateException.cs
- XPathException.cs
- _ConnectionGroup.cs
- InvalidComObjectException.cs
- InlineUIContainer.cs
- SchemaTypeEmitter.cs
- ObjectQueryExecutionPlan.cs
- TranslateTransform.cs
- CompoundFileStorageReference.cs
- SafeSecurityHelper.cs
- ListMarkerSourceInfo.cs
- WsatServiceCertificate.cs
- PrintingPermissionAttribute.cs
- ResourceContainerWrapper.cs
- RectAnimationClockResource.cs
- Crc32.cs
- AlphabeticalEnumConverter.cs
- SequentialOutput.cs
- WebPart.cs
- SafeViewOfFileHandle.cs
- ScrollableControlDesigner.cs
- PixelShader.cs
- TextTreeFixupNode.cs
- ConnectionOrientedTransportManager.cs
- AttributeQuery.cs
- PartitionResolver.cs
- WindowVisualStateTracker.cs
- WebBrowserPermission.cs
- SessionEndingCancelEventArgs.cs
- AccessorTable.cs
- WebBrowserBase.cs
- ScriptBehaviorDescriptor.cs
- ObjectStateEntryDbDataRecord.cs
- SynchronizedKeyedCollection.cs
- DataKeyCollection.cs
- Win32MouseDevice.cs
- RelationshipType.cs
- WorkflowServiceBuildProvider.cs
- StrokeIntersection.cs
- ThicknessConverter.cs
- TableRowCollection.cs
- BindingNavigator.cs
- ThreadPool.cs
- SecurityElementBase.cs
- BounceEase.cs
- ProcessManager.cs
- SmiRecordBuffer.cs
- StorageRoot.cs