views:

176

answers:

1

Using this MSDN Article as an example for pausing and resuming, one would assume that this would be pretty straight forward. This is how I'm "pausing" the workflow...

LastWfGuid = workflow.Id;
workflow.Unload();

Pretty simple, it's supposed to persist to the instance store (which I already set prior to these two lines) and I do see entries in the Instance view and the InstancesTable. When I'm ready to resume the workflow I do this...

workflow = new WorkflowApplication( myActivity, myWfArgs );
workflow.InstanceStore = wfStore;
workflow.Load(LastWfGuid);

At that point I get an InvalidOperationException with the exception message being...

Workflow inputs cannot be used with Load or LoadRunnableInstance, since they are only provided to new instances.

If I can't load a workflow that was previously persisted, how do I resume it again? I tried simply caling Persist() in place of Unload() and from the outside it looks ok and I receive no exception. But, the workflow continues to run it's course which is not what I'm looking for. I want to pause and then resume my workflow.

+1  A: 

Remove the myWfArgs argument when creating the WorkflowApplication used to load the existing workflow instance. So like this:

workflow = new WorkflowApplication(myActivity);
workflow.InstanceStore = wfStore;
workflow.Load(LastWfGuid);
Maurice
Just out of curiosity, how would that fix my load issue? Is there a reason why that would prevent a resume?
jlafay
This is great because it does what I need it to do. It pauses and resumes on demand. The only issue I have with this approach is how do I pass in my args that I need or are they part of the state when persisted?
jlafay
All data passed to the workflow during startup, as well as in variables in scope at the time, is saved and reloaded as part of the workflow state.
Maurice
That makes sense, can I still load a workflow after the app has terminated and is executed again? I'm working on that requirement next.
jlafay
Yes, the state is save in the SQL Server database using the SqlWorkflowInstanceStore.
Maurice