protected override void Execute(NativeActivityContext context)
        {
            ICancellableWorkItemWithChildren cancelationTarget = CancellableWorkItem.Get(context);

            if (cancelationTarget.HasCancellationRequested)
            {
                return;
            }

            PostTrackingRecord(context, cancelationTarget, WorkItemStatus.Executing);

            Debug.WriteLine("CancellableBookmark created: {0} - {1} -Workflow Id = {2} : {3}",
                            CancelableWorkItemBookmarkName(cancelationTarget.Id),
                            cancelationTarget.Name, context.WorkflowInstanceId, context.ActivityInstanceId);
            context.CreateBookmark(CancelableWorkItemBookmarkName(cancelationTarget.Id), OnWorkItemCanceled);

            context.ScheduleActivity(Action, onCompleted, onWorkItemFaulted);
        }
        private void onCompleted(NativeActivityContext context, ActivityInstance completedinstance)
        {
            ICancellableWorkItemWithChildren target = CancellableWorkItem.Get(context);

            if (completedinstance.State == ActivityInstanceState.Canceled ||
                completedinstance.State == ActivityInstanceState.Faulted)
            {
                string message = _childFault.Get(context) != null
                                     ? Resources.CancelledDueToAssociatedTaskFailure
                                     : Resources.CancelledUponUserRequest;

                MarkTasksAsCancelled(target, context, message);

                if (completedinstance.State == ActivityInstanceState.Faulted)
                {
                    PostTrackingRecord(context, target, WorkItemStatus.Faulted, Resources.FailedDueToChildTaskFailure);
                }
            }
            else
            {
                PostTrackingRecord(context, target, WorkItemStatus.Closed);
            }

            context.RemoveAllBookmarks();
            if ((completedinstance.State == ActivityInstanceState.Canceled) ||
                (completedinstance.State == ActivityInstanceState.Faulted))
            {
                _suppressCancel.Set(context, true);
                if (Cancelation != null)
                {
                    context.ScheduleActivity(Cancelation, OnCompensationActivityCompleted);
                }
                else
                {
                    OnCompensationActivityCompleted(context, completedinstance);
                }
            }
        }