protected override void Execute(NativeActivityContext context)
            {
                SendRequestReceiveResponseScopeExecutionProperty executionProperty = context.GetSendRequestReceiveResponseScopeExecutionProperty();

                if (executionProperty.UntypedOnOperationTask != null)
                {
                    // We await the task, but we won't execute the task's Func<Task> or Func<Task<TResponseResult>> return value, that is the ReceiveResponse activity's responsibility.
                    context.ScheduleAction(responseResultWaiter, executionProperty.UntypedOnOperationTask);
                    executionProperty.OnOperationTaskWaiterIsScheduled();
                }
            }
Esempio n. 2
0
        // This will start/schedule the OnOperationAsync task, but won't wait for it, the task will be an implicit (single threaded reentrant) parallel activity.
        // The Scope is responsible to handle the outstanding task in case of Abort, Cancellation or Termination.
        protected override void Execute(NativeActivityContext context)
        {
            SendRequestReceiveResponseScopeExecutionProperty executionProperty = context.GetSendRequestReceiveResponseScopeExecutionProperty();
            IActivityContext activityContext = context.GetActivityContext();

            executionProperty.StartOnOperationAsync(activityContext, OperationName);

            if (activityContext.TrackingEnabled)
            {
                context.Track(new SendRequestRecord(OperationName));
            }
        }
        // SendRequest has scheduled the OnOperation task, but didn't wait for it, the task is an implicit (single threaded reentrant) parallel activity,
        // the Scope is responsible to handle the outstanding task in case of Abort, Cancellation or Termination (like a virtual Task.WhenAll() method).
        protected override void Execute(NativeActivityContext context)
        {
            if (Body != null)
            {
                // The noPersistHandle will be exited when the activity completes or aborts, because
                // the handle is an execution property in the background, with a scope on this activity, so it will be removed.
                // Don't add Exit() to the Completion and/or Fault callback, because if this scope is in an external TryCatch,
                // this will first Fault, then Cancelled by the external TryCatch (if the fault propagation is handled), causing "unmatched exit" exception.
                noPersistHandle.Get(context).Enter(context);

                SendRequestReceiveResponseScopeExecutionProperty executionProperty = sendRequestReceiveResponseScopeExecutionPropertyFactory();
                context.Properties.Add(ExecutionPropertyName, executionProperty);
                context.ScheduleActivity(tryCatch);
            }
        }