protected override void OnUninitialize(HandleInitializationContext context) { if (this.bookmarkScope != null) { int scopeRefCount = this.bookmarkScope.DecrementHandleReferenceCount(); DisassociateInstanceKeysExtension extension = context.GetExtension <DisassociateInstanceKeysExtension>(); // We only unregister the BookmarkScope if the extension exists and is enabled and if we had the last reference to it. if ((extension != null) && extension.AutomaticDisassociationEnabled && (scopeRefCount == 0)) { context.UnregisterBookmarkScope(this.bookmarkScope); } } base.OnUninitialize(context); }
void InitializeFromConstructor(WorkflowService serviceDefinition, params Uri[] baseAddresses) { // first initialize some values to their defaults this.idleTimeToPersist = WorkflowIdleBehavior.defaultTimeToPersist; this.idleTimeToUnload = WorkflowIdleBehavior.defaultTimeToUnload; this.unhandledExceptionAction = WorkflowUnhandledExceptionBehavior.defaultAction; this.workflowExtensions = new WorkflowServiceHostExtensions(); // If the AppSettings.DefaultAutomaticInstanceKeyDisassociation is specified and is true, create a DisassociateInstanceKeysExtension, set its // AutomaticDisassociationEnabled property to true, and add it to the extensions collection so that System.Activities.BookmarkScopeHandle will // unregister its BookmarkScope, which will cause key disassociation. KB2669774. if (AppSettings.DefaultAutomaticInstanceKeyDisassociation) { DisassociateInstanceKeysExtension extension = new DisassociateInstanceKeysExtension(); extension.AutomaticDisassociationEnabled = true; this.workflowExtensions.Add(extension); } if (TD.CreateWorkflowServiceHostStartIsEnabled()) { TD.CreateWorkflowServiceHostStart(); } if (serviceDefinition != null) { this.workflowDefinitionProvider = new WorkflowDefinitionProvider(serviceDefinition, this); InitializeDescription(serviceDefinition, new UriSchemeKeyedCollection(baseAddresses)); } this.durableInstanceManager = new DurableInstanceManager(this); if (TD.CreateWorkflowServiceHostStopIsEnabled()) { TD.CreateWorkflowServiceHostStop(); } this.workflowServiceHostPerformanceCounters = new WorkflowServiceHostPerformanceCounters(this); }