I am trying to understand
- Difference between CacheMetadata and caching complete activity object in my own cache(some collection)
- Is there anyway I can improve performance of xaml based workflow.
We have something like...
public class BusinessRule
{
public DynamicActivity Activity { get; private set; }
public BusinessRule(string ruleSetAsXaml)
{
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(ruleSetAsXaml));
this.Activity = ActivityXamlServices.Load(stream) as DynamicActivity;
}
public void Execute(data objData)
{
Dictionary<string, object> inArgs = new Dictionary<string, object>();
inArgs.Add("data", objData);
if (this.Activity != null)
{
WorkflowInvoker invoker = new WorkflowInvoker(this.Activity);
outArgs = invoker.Invoke(inArgs);
}
}
}
And we have many business rules like this. The xamls are stored in database, all these rules are instantiated once and kept in a collection (in memory). These get called when required (with additional arguments) using Execute() method.
Now my question...Is there anyway I can make WorkflowInvoker.Invoke() more faster? Currently it is taking about 00:00:00.1214497 each call with CPU utilization of 25% (on this line) of complete process. It may also be noted that I am not doing anything tricky in xaml.
Am I doing anything wrong here? Do I need to cache meta data?