Esempio n. 1
0
            protected override void Execute(NativeActivityContext context)
            {
                ReceiveRequestSendResponseScopeExecutionProperty executionProperty = context.GetReceiveRequestSendResponseScopeExecutionProperty();

                if (!executionProperty.Faulted && !executionProperty.IsInitializedAndCompleted)
                {
                    // The taskCompletionSource from an incoming request is not completed (we don't have it or we have but not completed).
                    if (!executionProperty.IsInitializedButNotCompleted)
                    {
                        // We don't have taskCompletionSource from an incoming request.
                        if (executionProperty.Idempotent &&
                            context.GetPreviousResponseParameterExtension().TrySetResponseCanceled(executionProperty.OperationName))
                        {
                            context.ScheduleActivity(persist);
                        }
                    }
                    else
                    {
                        // We have taskCompletionSource from an incoming request, after setting the response in the extension we cancel the taskCompletionSource also.
                        if (executionProperty.Idempotent &&
                            context.GetPreviousResponseParameterExtension().TrySetResponseCanceled(executionProperty.OperationName))
                        {
                            context.ScheduleActivity(persist, PersistCompletionCallback);
                        }
                        else
                        {
                            executionProperty.TrySetTaskCompletionSourceCanceled();
                        }
                    }
                }
            }
        // We must persist before sending the response if we are idempotent, but this will cause double persist if the workflow goes idle after the response is sent.
        // TODO: can we do anything against this???
        protected override void Execute(NativeActivityContext context)
        {
            ReceiveRequestSendResponseScopeExecutionProperty <object> executionProperty = context.GetReceiveRequestSendResponseScopeExecutionProperty <object>();

            executionProperty.AssertIsInitialized();

            if (Idempotent)
            {
                context.GetPreviousResponseParameterExtension().SetResponseParameter(
                    executionProperty.OperationName, typeof(void), null);
                context.ScheduleActivity(persist, PersistCompletionCallback);
            }
            else
            {
                SetTaskCompletionSourceResult(executionProperty, context);
            }
        }