Is there any difference at all between the workflow definitions and the contents of the rules file or are they identical? When you create a workflow by loading from markup it is cached, and subsequent CreateWorkflow with the same contents will use the same
activity tree from the previous call. If they are different then a new activity tree is generated for each one, so subsequent calls are not as fast as they could be, and in fact they might get slower if there are many workflow definitions to compare to see
if there is an existing activity tree to use. If this is the case (and if it is the usual difference as property values on the root workflow) then you could make it so the definitions are the same, and you could pass in the different values as input arguments
to the workflow. if you have tracking enabled it will generate a different profile for each one if they are slightly different and that can slow things down as well.
If they are the same, then you could speed it up a couple of ways:
1. Turn off validation (you could do this if they are different, but if each one is different then you may want to keep this enabled inc ase one of the variations introduces a problem). if this markup is from a trusted source then you don't need to validate
each time you create an instance.
2. Compile the markup into an assembly (you can do this right from your hosting app) and then create the new instances using the type from the assembly and not the markup.
There are demos of these approaches in the following Xaml Workflow Workshop:
or you can jump right to the download here:
Hopefully this info helps, and if I have misunderstood your scenario please let me know and I can try to provide additional information.
Steve Danielson [Microsoft]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at