开发者

Should I use PageAsyncTask or manual Threading within In ASP.NET MVC Controller for parallel operations

开发者 https://www.devze.com 2022-12-19 02:17 出处:网络
I have an ASP.NET MVC application, and in one of the controllers I have two long-running operations.I w开发者_StackOverflowant to execute them in parallel.

I have an ASP.NET MVC application, and in one of the controllers I have two long-running operations. I w开发者_StackOverflowant to execute them in parallel.

At first, I simply rolled my own multithreading code by new'ing up a System.Threading.Thread() object, running it in the background, and thread.Join()ing it up before exiting the controller. Worked fine.

A co-worker pointed me at the System.Web.UI.PageAsyncTask class. It seems straightforward enough and event-driven, but it seems like it will work too.

Any compelling reason to choose PageAsyncTask over a simple Thread?

Thanks!

-Mike


PageAsyncTask should not be used in an MVC application. MVC 2 has an AsyncController class that can be used for this purpose instead. But if your operations are very simple and manual threading is working out for you, you're probably fine sticking with your current implementation.

0

精彩评论

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