Reputation: 2518
If I have have a WorkflowInstance
can I executed twice in a row?
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(...));
instance.start();
instance.start();
When I do this I get and exception telling me that I don't have a persistence service configured. However my question is: after I execute the WorkflowInstance
once can a instance be run a second time, or dos it become unusable? Do I have to create another instance everytime I want to executed?
Upvotes: 0
Views: 593
Reputation: 1531
As per Rutesh's answer, you cannot start the same instance twice. If the workflow has been unloaded (i.e. persisted) you can load the workflow again using WorkflowInstance.Load().
Upvotes: 0
Reputation: 34820
A workflow Instance, once started, moves forward through the workflow definition and then terminates. It cannot be "reused" to execute another workflow the way an object can be cached and reused.
There are several things you can do to improve the performance of your workflow, depending on how it is built.
Upvotes: 0
Reputation: 2518
Yes I see I can't start an instance twice. However, what I wanted was to create the instance once and be able to run the workflow several times.
My problem is that WorkflowInstance creation is somewhat heavy.
Upvotes: 0
Reputation: 17235
As per the specifications of WorkflowInstance you can start the instance only once
have a look at http://msdn.microsoft.com/en-us/library/system.workflow.runtime.workflowinstance.start.aspx
An InvalidOperationException is thrown if the instance is already running
Upvotes: 1