Beispiel #1
0
        private void OnWorkItemCancellationRequested(NativeActivityContext context, Bookmark bookmark, object value)
        {
            IWorkItemWithChildren workflowRoot = RootWorkItem.Get(context);
            List <Guid>           pathToChild  = workflowRoot.RouteFromParentToChild((Guid)value).Select(workItem => workItem.Id).ToList();

            CancelChildWorkItem(pathToChild, context);
        }
Beispiel #2
0
        protected override void Execute(NativeActivityContext context)
        {
            context.Track(CreateLookupTreeTrackingRecord(RootWorkItem.Get(context).CreateLookupTree()));

            context.CreateBookmark(CancellationBookmark, OnCancellationRequested, BookmarkOptions.MultipleResume);
            context.CreateBookmark(WorkItemCancellationBookmark, OnWorkItemCancellationRequested, BookmarkOptions.MultipleResume);

            context.ScheduleActivity(ProgressTrackingScope, OnProgressActivityCompleted);
        }
Beispiel #3
0
        private void CancelChildWorkItem(IList <Guid> parthToChild, NativeActivityContext context)
        {
            ICancellableWorkItemWithChildren cancellationRoot = RootWorkItem.Get(context).GoToChild(parthToChild)
                                                                as ICancellableWorkItemWithChildren;

            if (cancellationRoot != null)
            {
                BookmarkResumptionResult cancelationRequestResult = context.ResumeBookmark(
                    new Bookmark(WorkItemCancelationScope.CancelableWorkItemBookmarkName(cancellationRoot.Id)),
                    cancellationRoot);

                if (cancelationRequestResult != BookmarkResumptionResult.Success)
                {
                    WorkItemCancelationScope.MarkTasksAsCancelled(cancellationRoot, context, "Because cancellation request.");
                }
            }
        }