private bool Persist() { IAsyncResult result = null; try { if (this.operation == WorkflowServiceInstance.PersistenceOperation.Delete) { this.saveStatus = SaveStatus.Completed; } if (this.context == null) { this.context = new WorkflowServiceInstance.WorkflowPersistenceContext(this.instance, ((this.pipeline != null) && this.pipeline.IsSaveTransactionRequired) || this.isCompletionTransactionRequired, this.dependentTransaction, this.instance.persistTimeout); } using (base.PrepareTransactionalCall(this.context.PublicTransaction)) { result = this.instance.persistenceContext.BeginSave(this.data, this.saveStatus, this.instance.persistTimeout, this.PrepareInnerAsyncCompletion(persistedCallback), this); } } catch (InstancePersistenceException) { this.updateState = false; throw; } finally { if ((result == null) && (this.context != null)) { this.context.Abort(); } } return base.SyncContinue(result); }
private bool Save() { if (this.pipeline == null) { return this.NotifyCompletion(); } IAsyncResult result = null; try { if (this.context == null) { this.context = new WorkflowServiceInstance.WorkflowPersistenceContext(this.instance, this.pipeline.IsSaveTransactionRequired || this.isCompletionTransactionRequired, this.dependentTransaction, this.instance.persistTimeout); } this.instance.persistencePipelineInUse = this.pipeline; Thread.MemoryBarrier(); if (this.instance.abortingExtensions) { throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new OperationCanceledException(System.ServiceModel.Activities.SR.DefaultAbortReason)); } using (base.PrepareTransactionalCall(this.context.PublicTransaction)) { result = this.pipeline.BeginSave(this.timeoutHelper.RemainingTime(), this.PrepareInnerAsyncCompletion(savedCallback), this); } } finally { if (result == null) { this.instance.persistencePipelineInUse = null; if (this.context != null) { this.context.Abort(); } } } return base.SyncContinue(result); }
private bool NotifyCompletion() { if ((!this.isUnloaded || (this.instance.Controller.State != WorkflowInstanceState.Complete)) || (this.instance.creationContext == null)) { return this.CompleteContext(); } IAsyncResult result = null; try { if (this.context == null) { this.context = new WorkflowServiceInstance.WorkflowPersistenceContext(this.instance, this.isCompletionTransactionRequired, this.dependentTransaction, this.instance.persistTimeout); } using (base.PrepareTransactionalCall(this.context.PublicTransaction)) { result = this.instance.creationContext.OnBeginWorkflowCompleted(this.instance.completionState, this.instance.workflowOutputs, this.instance.terminationException, this.timeoutHelper.RemainingTime(), this.PrepareInnerAsyncCompletion(notifyCompletionCallback), this); if (result == null) { throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.WorkflowCompletionAsyncResultCannotBeNull)); } } } finally { if ((result == null) && (this.context != null)) { this.context.Abort(); } } return base.SyncContinue(result); }