workflow foundation 4 - workflowapplication and SynchronousSynchronizationContext in WCF -


i'm implementing stare machine application using wf 4.5; workflow hosted wcf service using workflowapplication class. it's intended used asp.net mvc application queries wcf service redirecting specific pages mapped states defined in state machine workflow. need execution of workflow should synchronous in order give mvc application current state when transition called; i'm forcing synchronoussynchronizationcontext described in article:

http://www.develop.com/synchworkflow

but i'm facing strange behavior; when call workflow application first time works fine , workflowapplication performs task in synchronous fashion. when call resume (the workflow persisted) through bookmark workflowapplication executes in async fashion event though i'm still forcing synchronous synchronizationcontext.

below there extract of code i'm using:

public class workflowmanager {     public guid run(activity activity, idictionary<string, object> parameters)     {         workflowapplication wfapp = setupinstance(activity, parameters);         wfapp.run();          return wfapp.id;     }      public void resume(guid id, activity activity, string bookmarkname)     {          workflowapplication wfapp = setupinstance(activity, null);         wfapp.load(id);          wfapp.resumebookmark(bookmarkname, "test");     }      workflowapplication setupinstance(activity activity, idictionary<string, object> parameters)     {         guid id = guid.empty;          workflowapplication wfapp = null;         if (parameters != null)         {             wfapp = new workflowapplication(activity, parameters);         }         else         {             wfapp = new workflowapplication(activity);         }          synchronoussynchronizationcontext synccontext = new synchronoussynchronizationcontext();         wfapp.synchronizationcontext = synccontext;          wfapp.idle = appidle;         wfapp.persistableidle = (e) =>         {             return persistableidleaction.unload;         };         wfapp.aborted = appaborted;         wfapp.onunhandledexception = appexception;          changedstatenotifier extensionnotifier = new changedstatenotifier();         extensionnotifier.notification += delegate(object sender, hostnotifyeventargs e)         {             if (changedstate != null)             {                 changedstate(e.workflowid, e.workflowstatus);             }         };          wfapp.instancestore = store;         wfapp.extensions.add(extensionnotifier);          return wfapp;     } } 

i appreciate give me hint @ i'm doing wrong. , regards.

example http://www.develop.com/synchworkflow not functional. implementation of sync context handles invocation until idle or abort events executed different threads. same resumebookmark. little bit more complex implementation of sync context required. there example in .net framework (though private class cannot used). class pumpbasedsynchronizationcontext in system.activities.workflowapplication, system.activities.

similar question is: how execute workflowapplication synchronously


Comments