private void ScheduleSecondaryRoot(NativeActivityContext context, CompensationExtension compensationExtension, CompensationTokenData token)
        {
            if (token.ParentCompensationId != CompensationToken.RootCompensationId)
            {
                CompensationTokenData parentToken = compensationExtension.Get(token.ParentCompensationId);
                Fx.Assert(parentToken != null, "parentToken must be valid");

                parentToken.ExecutionTracker.Add(token);
            }
            else
            {
                CompensationTokenData parentToken = compensationExtension.Get(CompensationToken.RootCompensationId);
                Fx.Assert(parentToken != null, "parentToken must be valid");

                parentToken.ExecutionTracker.Add(token);
            }

            // If we are going to Cancel, don't set the out arg...
            if (Result != null && token.CompensationState == CompensationState.Completed)
            {
                Result.Set(context, _currentCompensationToken.Get(context));
            }

            Fx.Assert(token.BookmarkTable[CompensationBookmarkName.OnSecondaryRootScheduled] == null, "Bookmark should not be already initialized in the bookmark table.");
            token.BookmarkTable[CompensationBookmarkName.OnSecondaryRootScheduled] = context.CreateBookmark(new BookmarkCallback(OnSecondaryRootScheduled));

            _compensationId.Set(context, token.CompensationId);

            context.ScheduleSecondaryRoot(CompensationParticipant, context.Environment);
        }
Example #2
0
 internal void SetupWorkflowCompensationBehavior(NativeActivityContext context, BookmarkCallback callback, Activity workflowCompensationBehavior)
 {
     this.WorkflowCompensationScheduled = context.CreateBookmark(callback);
     context.ScheduleSecondaryRoot(workflowCompensationBehavior, null);
     this.Add(0L, new CompensationTokenData(0L, 0L));
     this.IsWorkflowCompensationBehaviorScheduled = true;
 }
        internal void SetupWorkflowCompensationBehavior(NativeActivityContext context, BookmarkCallback callback, Activity workflowCompensationBehavior)
        {
            this.WorkflowCompensationScheduled = context.CreateBookmark(callback);

            Fx.Assert(workflowCompensationBehavior != null, "WorkflowCompensationBehavior must be valid");
            context.ScheduleSecondaryRoot(workflowCompensationBehavior, null);

            // Add the root compensationToken to track all root CA execution order.
            this.Add(CompensationToken.RootCompensationId, new CompensationTokenData(CompensationToken.RootCompensationId, CompensationToken.RootCompensationId));
            this.IsWorkflowCompensationBehaviorScheduled = true;
        }
 private void ScheduleSecondaryRoot(NativeActivityContext context, CompensationExtension compensationExtension, CompensationTokenData token)
 {
     if (token.ParentCompensationId != 0L)
     {
         compensationExtension.Get(token.ParentCompensationId).ExecutionTracker.Add(token);
     }
     else
     {
         compensationExtension.Get(0L).ExecutionTracker.Add(token);
     }
     if ((base.Result != null) && (token.CompensationState == CompensationState.Completed))
     {
         base.Result.Set(context, this.currentCompensationToken.Get(context));
     }
     token.BookmarkTable[CompensationBookmarkName.OnSecondaryRootScheduled] = context.CreateBookmark(new BookmarkCallback(this.OnSecondaryRootScheduled));
     this.compensationId.Set(context, token.CompensationId);
     context.ScheduleSecondaryRoot(this.CompensationParticipant, context.Environment);
 }
        internal void SetupWorkflowCompensationBehavior(NativeActivityContext context, BookmarkCallback callback, Activity workflowCompensationBehavior)
        {
            this.WorkflowCompensationScheduled = context.CreateBookmark(callback);

            Fx.Assert(workflowCompensationBehavior != null, "WorkflowCompensationBehavior must be valid");
            context.ScheduleSecondaryRoot(workflowCompensationBehavior, null);

            // Add the root compensationToken to track all root CA execution order.
            this.Add(CompensationToken.RootCompensationId, new CompensationTokenData(CompensationToken.RootCompensationId, CompensationToken.RootCompensationId));
            this.IsWorkflowCompensationBehaviorScheduled = true;
        }
 internal void SetupWorkflowCompensationBehavior(NativeActivityContext context, BookmarkCallback callback, Activity workflowCompensationBehavior)
 {
     this.WorkflowCompensationScheduled = context.CreateBookmark(callback);
     context.ScheduleSecondaryRoot(workflowCompensationBehavior, null);
     this.Add(0L, new CompensationTokenData(0L, 0L));
     this.IsWorkflowCompensationBehaviorScheduled = true;
 }