SynchronizationContext and Bookmarks in WF4

Posted by DBatisse on Stack Overflow See other posts from Stack Overflow or by DBatisse
Published on 2010-05-22T12:22:32Z Indexed on 2010/05/22 12:30 UTC
Read the original article Hit count: 501

Filed under:

I am running workflows under asp.net and using SynchronizationContext to make the page "wait" for the workflow. Here is how I run the workflow instance under asp.net:

var workflowApplication = new WorkflowApplication(activity);
SynchronizationContext syncContext = SynchronizationContext.Current;
workflowApplication.Completed = delegate { syncContext.OperationCompleted(); };
workflowApplication.SynchronizationContext = syncContext;
syncContext.OperationStarted();
workflowApplication.Run();

In one of the activities I use a bookmark. Now I want the page processing to continue whenever I call CreateBookmark. I tried calling SynchronizationContext.Current.OperationCompleted() before setting the bookmark but that crushes asp.net site when the workflow resumes and completes (I think the workflow instance calls OperationCompleted again when it completes and the error raises)

How can I work with bookmarks under Asp.Net, any ideas?

© Stack Overflow or respective owner

Related posts about workflow-foundation-4