Reputation: 1125
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?
Upvotes: 4
Views: 2361
Reputation: 1
Two years later... The best way is :
class SynchronousSynchronizationContext : SynchronizationContext
{
public override void Post(SendOrPostCallback d, object state)
{
this.Send(d, state);
}
}
Upvotes: 0
Reputation: 27632
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.
Upvotes: 5