I was wondering if there are ways to use Windows Workflow Foundation to create workflows at run time. I read about dynamic workflows but it is not wat I want. From what I understood, we are able to modify some actions and parameters of a workflow at runtime. In my case, I would like to create a brand new wor开发者_高级运维kflow at runtime.
Any ideas?
Thank you
You can always create new workflow models and execute them. For example,
Sequence wf = new Sequence
{
Activities = {
new WriteLine {Text = "Hello"},
new WriteLine {Text = "World"}
}
};
WorkflowInvoker.Invoke(wf);
You can create workflow XAML and load it to create an workflow.
EDIT:
Check System.Activities
namespaces in WF4 - the main System.Activities namespace allows you to create workflow using code (as opposed to using design surface or XAML). Use
WorkflowInvoker to invoke such workflow. Essentially, an activity represents the workflow and activity can be composed on several child activities.
You can use WorkflowApplication
when you need more control - persistance, life cycle events etc. See http://msdn.microsoft.com/en-us/library/dd560894.aspx
Here are few other links that you may find useful:
http://msdn.microsoft.com/en-us/library/ee342461.aspx
http://www.codeproject.com/KB/WF/OperationWorkflowInvoker4.aspx
精彩评论