Creating an Input Message activity using Bookmark

When a workflow is running and we want to send a message to the workflow during run time, how can we achieve this? We can use Bookmark to achieve this. In this task, we will create an activity using Bookmark, which will function as a message input activity.

How to do it...

  1. Create the InputMessage activity:

    Add a new code file to the ActivityLibrary project named InputMessage.cs. Then, replace all the default code with the following code:

    using System.Activities; public class InputMessage<T>:NativeActivity { public InArgument<string> bookmarkName { get; set; } public OutArgument<T> result { get; set; } protected override void Execute(NativeActivityContext context){ context.CreateBookmark(bookmarkName.Get(context), ...

Get Microsoft Windows Workflow Foundation 4.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.