Search code examples
workflow-foundation-4

How to resume a bookmark from within a NativeActivity?


I have an activity that schedules an operation to an external API and then has to continue only when this external API finishes, which is indicated by an Event. I currently use a NativActitivy.

my idea would have been to set a bookmark and then register an event handler that would trigger the bookmark. Sadly, it seems I can not resume a bookmark wihtout a context.

What is the best way to do that?

The flow is this: * Activity starts * Activity sets bookmark for external API completion. * Avtiovity calls into external API AND registers event handler * Activity event handler listens to all completion events until the right one comes (there is a paramter that identifies which request was completed) * Activity then resumes the bookmark and completes.

Anyone has a code sample for that? I currently use a natie activity but am willing to change.


Solution

  • You must create an extension to do it. Think about it: While you are waiting for the external event to occur, your workflow is idle. So you need a guy(IWorkflowInstanceExtension) outside your workflow to bring things up again

    Examples at:

    http://blogs.msdn.com/b/patcarna/archive/2010/01/19/windows-workflow-4-0-workflow-instance-extensions.aspx

    http://msmvps.com/blogs/theproblemsolver/archive/2010/01/27/using-wf4-bookmarks-with-iworkflowinstanceextension.aspx