Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

How to execute 5 stored procedures parallel using asp.net mvc .
In my action method I need execute 5 stored procedures, but each sp take 2 to 3 seconds.
after execution complted 5 sp's it will take 10 to 12 seconds. I need to execute 5 sp's parallelly.
Posted
Updated 1-Mar-15 18:07pm
v3

The first question you should consider is that are these procedures dependent on the same data and is that data being modified. In other words can the procedures be executed in any order without affecting the result?

The second question is, are the procedures still modifying the same data. If they are, you may have a big chance of locking conflicts, even deadlocks.

If the either of the above questions is true, you probably shouldn't be using asynchronous calls.

Also before going to asynchronous model, you should investigate if the performance of the procedures can be enhanced. Are they executed in an optimal way. If the roundtrips are taking the time, why not create a small procedure which calls these procedures. This way you can use only single call from the client side.

And after all if you decide to use asynchronous executions, first you need to open 5 separate connections and then with each connection you can use methods like SqlCommand.BeginExecuteNonQuery[^] or SqlCommand.BeginExecuteNonQuery Method (AsyncCallback, Object)[^]
 
Share this answer
 
Comments
NagaRaju Pesarlanka 2-Mar-15 1:33am    
Thanks for replied me.
5 procedures result different and unique.
Is there any possible to async calls using entity framework? if yes, How?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900