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
- BitmapImage.cs
- X509CertificateStore.cs
- DependencySource.cs
- ColorConvertedBitmapExtension.cs
- RulePatternOps.cs
- MetafileEditor.cs
- ModelUIElement3D.cs
- SQLBytesStorage.cs
- FactoryGenerator.cs
- Process.cs
- GradientSpreadMethodValidation.cs
- StrokeSerializer.cs
- ProgressBar.cs
- PersonalizationProvider.cs
- JsonFormatMapping.cs
- DesignerActionHeaderItem.cs
- PasswordRecovery.cs
- SkipStoryboardToFill.cs
- SchemaManager.cs
- DesignerHierarchicalDataSourceView.cs
- SubMenuStyleCollection.cs
- RegexEditorDialog.cs
- PropertyDescriptorComparer.cs
- DownloadProgressEventArgs.cs
- UnhandledExceptionEventArgs.cs
- OdbcCommandBuilder.cs
- EntityContainer.cs
- DnsEndpointIdentity.cs
- ProxyWebPart.cs
- EntityContainerRelationshipSetEnd.cs
- TextRunTypographyProperties.cs
- BaseDataBoundControl.cs
- DataStorage.cs
- PrivilegeNotHeldException.cs
- SelectedPathEditor.cs
- OptionUsage.cs
- NativeMethods.cs
- ChannelDemuxer.cs
- GetUserPreferenceRequest.cs
- ApplicationTrust.cs
- DataPager.cs
- ExpressionCopier.cs
- ErrorTableItemStyle.cs
- ToolboxBitmapAttribute.cs
- TaskForm.cs
- CngKey.cs
- CounterSample.cs
- MarshalByRefObject.cs
- ReaderOutput.cs
- CompositeControl.cs
- MessageQueueKey.cs
- SettingsPropertyWrongTypeException.cs
- SplineQuaternionKeyFrame.cs
- EdgeModeValidation.cs
- ExtendLockCommand.cs
- ClientSponsor.cs
- basenumberconverter.cs
- NotifyIcon.cs
- XmlCharType.cs
- X509Certificate.cs
- IdentifierService.cs
- SqlFactory.cs
- DesignerObject.cs
- TypedDatasetGenerator.cs
- SkewTransform.cs
- activationcontext.cs
- TypeReference.cs
- precedingquery.cs
- ConnectionManagementSection.cs
- XmlDataSource.cs
- WindowsFormsHelpers.cs
- DataBindingExpressionBuilder.cs
- CollectionContainer.cs
- SiteMapNode.cs
- UMPAttributes.cs
- MenuAutomationPeer.cs
- StyleSelector.cs
- VBCodeProvider.cs
- TaskCanceledException.cs
- CallTemplateAction.cs
- tooltip.cs
- XamlFxTrace.cs
- ConfigurationElementProperty.cs
- ListViewItemCollectionEditor.cs
- TrustSection.cs
- RemotingConfigParser.cs
- NavigationPropertyEmitter.cs
- WebPart.cs
- FrameworkObject.cs
- XmlValidatingReaderImpl.cs
- ProcessInputEventArgs.cs
- ControlBindingsConverter.cs
- DecimalStorage.cs
- PrivilegeNotHeldException.cs
- XmlEncodedRawTextWriter.cs
- ViewLoader.cs
- SignatureToken.cs
- PageCatalogPart.cs
- WebPartCatalogCloseVerb.cs
- TlsSspiNegotiation.cs