4
votes

I would like to execute workflow using WorkflowApplication synchronously on calling thread.

Link http://msmvps.com/blogs/theproblemsolver/archive/2011/01/07/doing-synchronous-workflow-execution-using-the-workflowapplication.aspx provides one example but Idle and Abort events are still being executed on separate threads.

Is there something in framework that already provides full sync execution or I will have to write it?

2

2 Answers

5
votes

The workflow runtime, regardless of the host you choose, is always asynchronous. There is nothing you can do about it beyond using a different SynchronizationContext or blocking the thread until the workflow is done. Ron Jacobs has a similar approach using a ManualResetEvent with his Workflow Episodes.

0
votes

Two years later... The best way is :

class SynchronousSynchronizationContext : SynchronizationContext
{
    public override void Post(SendOrPostCallback d, object state)
    {
        this.Send(d, state);
    }
}