Reputation: 19067
I'm trying to understand the .NET Workflow Foundation a bit better, especially how the persist / unload and resume functionality works.
So for test purposes I created a very simple Activity and attempted to host it in a WorkflowApplication
. I'd like to learn how to use the ability to persist the workflow instances when they are idle. So I wrote the following code:
var store = new SqlWorkflowInstanceStore("......");
var identity = new WorkflowIdentity("MyAwesomeWorkflow", Version.Parse("1.0"), String.Empty);
var activity = new Sequence()
{
Activities =
{
new WriteLine() {Text = "hello"},
new Delay() {Duration = TimeSpan.FromSeconds(5)},
new WriteLine() {Text = "bye"},
}
};
var wfapp = new WorkflowApplication(activity, identity);
var resetEvent = new ManualResetEventSlim();
wfapp.InstanceStore = store;
wfapp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
{
Console.WriteLine("Persistable idle");
return PersistableIdleAction.Unload;
};
wfapp.Completed += delegate(WorkflowApplicationCompletedEventArgs eventArgs)
{
Console.WriteLine("completed");
resetEvent.Set();
};
wfapp.Run();
resetEvent.Wait();
The workflow is unloaded when the Delay
Activity starts, but it is not resumed when the Delay
is over. I'm not a Workflow Foundation expert, so I realize I must be using the API incorrectly. According to my collegaues, the Workflow should automatically wake up and resume execution when the Delay
is over.
I've read this MSDN article on the topic but it doesn't seem to explain this aspect very well.
Upvotes: 1
Views: 270
Reputation: 19067
In the meantime I've figured it out. Since nobody has posted an answer, I'll just post it here just in case somebody is looking for a solution.
Basically, the Workflow Engine does not support automatic resumption of workflow instances. It is misleading somewhat, but WorkflowApplication
does not support this.
So you could:
WorkflowServiceHost
which implements the same polling under the hoodUpvotes: 3