开发者

Optimizing Windows WF 3.5 Instance Creation for 200 request

开发者 https://www.devze.com 2023-04-10 10:54 出处:网络
I currently have a process that creates a windows wf 3.5 instance for each account that a customer have.

I currently have a process that creates a windows wf 3.5 instance for each account that a customer have.

foreach (Account acct in Customer.Accounts)
                {
                    Dictionary<string, object> param = new Dictionary<string, object>();
                    param.Add("account", acct);

                    //create the workflow instance
               开发者_如何学Python     WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(AcctWorkflow), param);

                    //start and run the workflow
                    instance.Start();
                    scheduler.RunWorkflow(instance.InstanceId);                    
                }

currently the creation of each request is about 500ms, but given 200 accounts, the total time > 1 min.

this is created real time as the user clicks on a create request button.

Please advise if there is any thing else i can do to make it faster.


I'm not sure what can be done for WF3.5 to speed things up. The WF3.5 run-time engine has many inherent "lack of optimization" problems that just can't be fixed or worked around (especially the way looping constructs, such as the While activity, are implemented).

If it is feasible for your project you should really consider re-writing it into WF4. The run-time engine for WF4 is a complete rewrite with a strong consideration for large+fast workflows. See http://msdn.microsoft.com/en-us/library/gg281645.aspx for a speed comparison of the WF3.5 vs WF4 run-time engines.

Even if it is not possible to rewrite your workflow into WF4, you should update to run the 3.5 workflow using the 4 engine (via the WF4 Interop activity). This could still potentially double your speed over using the WF3.5 engine. See the bottom of the page of the link above for the comparison using the Interop activity.

0

精彩评论

暂无评论...
验证码 换一张
取 消