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
- DataRowCollection.cs
- BitArray.cs
- LeftCellWrapper.cs
- GridItemProviderWrapper.cs
- DocumentPaginator.cs
- Visitor.cs
- XmlUtil.cs
- TextDecoration.cs
- ConsoleTraceListener.cs
- TextRunTypographyProperties.cs
- ToolboxComponentsCreatingEventArgs.cs
- BaseCodeDomTreeGenerator.cs
- oledbmetadatacollectionnames.cs
- RegionIterator.cs
- Attributes.cs
- ResourceDictionaryCollection.cs
- LineServicesRun.cs
- GregorianCalendarHelper.cs
- DataPagerFieldItem.cs
- InvalidDataException.cs
- AssemblyNameProxy.cs
- HttpBindingExtension.cs
- LicenseContext.cs
- FrugalList.cs
- CodeSnippetTypeMember.cs
- WebPartMenu.cs
- ConstructorNeedsTagAttribute.cs
- DescendantOverDescendantQuery.cs
- OleDbRowUpdatedEvent.cs
- FlowLayout.cs
- ParameterEditorUserControl.cs
- ManualWorkflowSchedulerService.cs
- _ContextAwareResult.cs
- DesignerSerializationVisibilityAttribute.cs
- ZeroOpNode.cs
- CalendarDay.cs
- SoapEnumAttribute.cs
- XmlSchemaProviderAttribute.cs
- FieldReference.cs
- ByteAnimation.cs
- NativeDirectoryServicesQueryAPIs.cs
- ParseChildrenAsPropertiesAttribute.cs
- IFlowDocumentViewer.cs
- AppDomainManager.cs
- Vector.cs
- DomainConstraint.cs
- DataControlLinkButton.cs
- SqlPersonalizationProvider.cs
- wgx_render.cs
- DocumentXPathNavigator.cs
- PartBasedPackageProperties.cs
- PropertyDescriptor.cs
- AnnotationHelper.cs
- MethodCallConverter.cs
- ElementHostPropertyMap.cs
- ArrayTypeMismatchException.cs
- HandlerWithFactory.cs
- XamlSerializer.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- RowsCopiedEventArgs.cs
- Canvas.cs
- SoapInteropTypes.cs
- ExpandedWrapper.cs
- StateMachineWorkflowInstance.cs
- BamlLocalizableResourceKey.cs
- FontDriver.cs
- TargetControlTypeAttribute.cs
- ButtonField.cs
- ParameterCollection.cs
- HostProtectionException.cs
- Monitor.cs
- ToolBarPanel.cs
- VisualStyleTypesAndProperties.cs
- HttpListener.cs
- DataGridViewElement.cs
- Parser.cs
- SortAction.cs
- AppearanceEditorPart.cs
- FixedTextContainer.cs
- Baml6Assembly.cs
- BeginGetFileNameFromUserRequest.cs
- TemplateControlParser.cs
- Exception.cs
- XmlSchemaValidationException.cs
- ParseNumbers.cs
- PieceDirectory.cs
- CompiledXpathExpr.cs
- SimpleModelProvider.cs
- Atom10FormatterFactory.cs
- AssociationSet.cs
- SchemaImporterExtensionsSection.cs
- ToolTip.cs
- MaterializeFromAtom.cs
- TemplateBindingExtensionConverter.cs
- TreeWalkHelper.cs
- ProcessHost.cs
- CommandConverter.cs
- followingsibling.cs
- HttpModuleCollection.cs
- InteropBitmapSource.cs