Jason Meckley
Jason Meckley

Reputation: 7591

Workflow foundation - multiple bookmarks

We have a state machine implemented as a windows workflow. The idea should be straight forward:

  1. load workflow
  2. preform activity
  3. stop (wait for user to start next step)

Our team is learning WWF as we go. we found a bookmark can be creataed to pause and unload the workflow. The workflow can then be resumed by loading the workflow by ID and resuming the bookmark.

//start
var workflow = new WorkflowApplication(new MyWorkflow(), identity);
workflow.Run();
//run step 1, create bookmark in transition 1

//.....
//resume
var workflow = new WorkflowApplication(new MyWorkflow(), identity);
workflow.Load(id);
workflow.ResumeBookmark("step 2", obj);
//run step 2. finish

This part works. But now we want to introduce a third step. Transition 2 should create a new bookmark and then resume the workflow to run step 3.

//run step 3
var workflow = new WorkflowApplication(new MyWorkflow(), identity);
workflow.Load(id);
workflow.ResumeBookmark("step 3", obj);
//run step 3. finish

However this is not working as expected. The workflow is loaded, but resuming step 3 bookmark doesn't execute the step 3 activity. It seems like either a workflow can only handle 1 bookmark, or the first bookmark in transition 1 is not cleared/removed after resuming with step 2.

I searched the internet but I haven't found enough information on this subject. There are plenty of examples of using a single bookmark in a workflow. But nothing on multiple bookmarks in a workflow.

Upvotes: 1

Views: 1130

Answers (2)

Kasun Koswattha
Kasun Koswattha

Reputation: 2461

OKay, I found this and worked for me. MSDN

Assuming you are overriding CanInduceIdle in all your bookmark creations, you just need to persist the workflow in the Idle. Add below in your resumption code.

     application.PersistableIdle = e => PersistableIdleAction.Persist;
     application.PersistableIdle = e => PersistableIdleAction.Unload;

Upvotes: 0

Tomas Jakl
Tomas Jakl

Reputation: 126

I've worked with StateMachine type and lot of bookmarks in WWF 4.5 without any problems. Our team have implemented helpdesk type of application, so bookmarks were placed in Action activities of Transitions. When workflow come to State, all Action activities of all transitions from State are triggered and bookmarks created. Resuming one of the bookmarks will clear all other bookmars and move StateMachine to another State, so new Transitions and bookmarks can be created.

Upvotes: 2

Related Questions