任务并行库在生产服务器上消耗大量 space
Task Parallel Library consuming lots of space on production server
我正在使用 –
Task task = new Task(delegate { GetRecordsForEmailReplies(headingList, partialEntity); });
task.Start();
to run some heavy methods, but the problem is it’s consuming lots of
space of CPU on server some time IIS Work process increased above 60%
thats why server gets stuck.
是否有解决此问题的解决方案,请告诉我?或 运行 这些繁重的方法而不阻塞页面加载的任何其他选项?
创建新 Task
或 Task<T>
的建议方法是将 Task.Factory.StartNew
与 .NET 4.0 或 [=14= 一起使用] 与 .NET 4.5。 Stephen Toub here对该主题有详细的解释。
他解释说这样更有效率:
For example, we take a lot of care within TPL to make sure that when accessing tasks from multiple threads concurrently, the "right" thing happens. A Task is only ever executed once, and that means we need to ensure that multiple calls to a task's Start method from multiple threads concurrently will only result in the task being scheduled once.
同样,使用 Task.Run
代替:
Task.Run(() => GetRecordsForEmailReplies(headingList, partialEntity));
我正在使用 –
Task task = new Task(delegate { GetRecordsForEmailReplies(headingList, partialEntity); });
task.Start();
to run some heavy methods, but the problem is it’s consuming lots of space of CPU on server some time IIS Work process increased above 60% thats why server gets stuck.
是否有解决此问题的解决方案,请告诉我?或 运行 这些繁重的方法而不阻塞页面加载的任何其他选项?
创建新 Task
或 Task<T>
的建议方法是将 Task.Factory.StartNew
与 .NET 4.0 或 [=14= 一起使用] 与 .NET 4.5。 Stephen Toub here对该主题有详细的解释。
他解释说这样更有效率:
For example, we take a lot of care within TPL to make sure that when accessing tasks from multiple threads concurrently, the "right" thing happens. A Task is only ever executed once, and that means we need to ensure that multiple calls to a task's Start method from multiple threads concurrently will only result in the task being scheduled once.
同样,使用 Task.Run
代替:
Task.Run(() => GetRecordsForEmailReplies(headingList, partialEntity));