private void InvokeDelegate(Activity currentContextActivity, Activity targetContextActivity, T e, bool sync, bool transacted) { ActivityExecutorDelegateOperation <T> item = null; if (this.delegateValue != null) { item = new ActivityExecutorDelegateOperation <T>(this.activityQualifiedName, this.delegateValue, e, this.ContextId); } else { item = new ActivityExecutorDelegateOperation <T>(this.activityQualifiedName, this.eventListener, e, this.ContextId); } bool flag = this.MayInvokeDelegateNow(currentContextActivity); if (flag && sync) { Activity activity = targetContextActivity.GetActivityByName(this.activityQualifiedName); using (currentContextActivity.WorkflowCoreRuntime.SetCurrentActivity(activity)) { item.SynchronousInvoke = true; item.Run(currentContextActivity.WorkflowCoreRuntime); return; } } Activity activityByName = targetContextActivity.GetActivityByName(this.activityQualifiedName); currentContextActivity.WorkflowCoreRuntime.ScheduleItem(item, ActivityExecutionContext.IsInAtomicTransaction(activityByName), transacted, !flag); }
private void InvokeDelegate(Activity currentContextActivity, Activity targetContextActivity, T e, bool sync, bool transacted) { ActivityExecutorDelegateOperation delegateOperation = null; if (this.delegateValue != null) { delegateOperation = new ActivityExecutorDelegateOperation(this.activityQualifiedName, this.delegateValue, e, this.ContextId); } else { delegateOperation = new ActivityExecutorDelegateOperation(this.activityQualifiedName, this.eventListener, e, this.ContextId); } bool mayInvokeDelegateNow = MayInvokeDelegateNow(currentContextActivity); if (mayInvokeDelegateNow && sync) { Activity targetActivity = targetContextActivity.GetActivityByName(this.activityQualifiedName); using (currentContextActivity.WorkflowCoreRuntime.SetCurrentActivity(targetActivity)) { delegateOperation.SynchronousInvoke = true; delegateOperation.Run(currentContextActivity.WorkflowCoreRuntime); } } else { // If in atomic and subscriber not in same scope // Queue it on the subscriber's baseExecutor Activity targetActivity = targetContextActivity.GetActivityByName(this.activityQualifiedName); currentContextActivity.WorkflowCoreRuntime.ScheduleItem(delegateOperation, ActivityExecutionContext.IsInAtomicTransaction(targetActivity), transacted, !mayInvokeDelegateNow); } }