private bool MayInvokeDelegateNow(Activity currentContextActivity) { // Ok to invoke right away if // subscriber wants to participate in the current transaction if ((this.activityQualifiedName == null) || (this.wantInTransact)) { return(true); } // If not in atomic scope at all, if (!ActivityExecutionContext.IsInAtomicTransaction(currentContextActivity.WorkflowCoreRuntime.CurrentActivity)) { return(true); } // Has not started executing yet, queue it up for now // Not letting it leak out for recv case any more Activity targetContextActivity = currentContextActivity.WorkflowCoreRuntime.GetContextActivityForId(this.contextId); if (targetContextActivity == null) { return(false); } // or in atomic and subscriber in same scope, // or in an atomic scope that's not in executing state, e.g. need to fire Scope closed status Activity targetActivity = targetContextActivity.GetActivityByName(this.activityQualifiedName, true); if (targetActivity == null) { return(false); } if (ActivityExecutionContext.IsInAtomicTransaction(targetActivity) && ActivityExecutionContext.IsInAtomicTransaction(currentContextActivity.WorkflowCoreRuntime.CurrentActivity)) { return(true); } // If the activity receiving the subscription is the scope itself if (targetActivity.MetaEquals(currentContextActivity)) { return(true); } return(false); }
private bool MayInvokeDelegateNow(Activity currentContextActivity) { if ((this.activityQualifiedName == null) || this.wantInTransact) { return(true); } if (!ActivityExecutionContext.IsInAtomicTransaction(currentContextActivity.WorkflowCoreRuntime.CurrentActivity)) { return(true); } Activity contextActivityForId = currentContextActivity.WorkflowCoreRuntime.GetContextActivityForId(this.contextId); if (contextActivityForId == null) { return(false); } Activity activityByName = contextActivityForId.GetActivityByName(this.activityQualifiedName, true); if (activityByName == null) { return(false); } return((ActivityExecutionContext.IsInAtomicTransaction(activityByName) && ActivityExecutionContext.IsInAtomicTransaction(currentContextActivity.WorkflowCoreRuntime.CurrentActivity)) || activityByName.MetaEquals(currentContextActivity)); }