I am trying to find a better way to wait for a number of I / O completion ports to finish.
For this scenario, let's say I'm in the MVC3 web application. (My understanding of using I / O ports here is recommended, so I can return the original stream back to IIS to serve other requests)
Suppose I have an array of identifiers, and I want to get an object for each identifier from some network call.
What is the best way to parallelize this synchronous method?
public class MyController: Controller { public ActionResult Index(IEnumerable<int> ids) { ids.Select(id => _context.CreateQuery<Order>("Orders") .First(o => o.id == id)); DataServiceQuery<Order> query = _context.CreateQuery<Order>("Orders"); return Json(query); } private DataServiceContext _context;
I know it would start like this:
public class MyController: AsyncController { public void IndexAsync(IEnumerable<int> ids) {
Should I use the DataServiceContext.BeginExecute Method? DataServiceContext.BeginExecuteBatch ? The data service that I consume can only receive one record at a time (this is not in my control), and I want these separate requests to be executed in parallel.
source share