开发者

What is the MaxSimultaneousWorkflows replacement?

MAIN QUESTION:

I am using Workflow Foundation 4.0 in which the WorkflowRuntime has been replaced by the WorkflowApplication as a workflow host for a single instance.

I am looking to control the number of concurrent Workflow instances running simultaneously. In WF 3.5 and earlier, one could set the MaxSimultaneousWorkflows property on the DefaultWorkflowSchedulerService used by WorkflowRuntime and such throttling could be achieved. How can I do the same using WF 4.0?

BACKGROUND AND WHY I WANT TO DO THIS

In my application, I want to schedule hundreds of workflow instances concurrently and I am creating a new instance of WorkflowApplication for each of them and calling "run" on the WorkflowApplication in a loop.

Each WorkflowApplication has its own DbContext instance which it uses for persistence and reading of data from SqlServer.

Everything works great when the number of WorkflowApplication threads running simultaneously is reasonably small amount (say couple of dozen instances). However, when I test the app with hundreds of workflow instances scheduled, I am seeing that the SqlConnection being used by DbContext times out waiting for a thread from the ThreadPool.

Hence, I want to throttle the maximum number of WorkflowApplication instances that can run to about 50% of what .Net decides by default so that a reasonable number of threads are still l开发者_高级运维eft in the .NET ThreadPool for SqlConnection and Asp.Net (which is also running on the machine in a separate AppDomain).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜