c# - How can i make Recursion Asynchronous using Async and Await Keyword? -


i getting multi-level dynamic menus database. have called want make async.
here code;

protected override void onactionexecuting(actionexecutingcontext filtercontext) {     var menus = uow.menus.getall()         .select(m => new parentmenuviewmodel()         {             menuid = m.menuid,             name = m.name,             parentid = m.parentid         })         .tolist<parentmenuviewmodel>();     viewbag.menus = createvm(0, menus);     base.onactionexecuting(filtercontext); }  public ienumerable<parentmenuviewmodel> createvm(int parentid, list<parentmenuviewmodel> list) {     return list.where(m=> m.parentid==parentid)         .select(m=> new parentmenuviewmodel()         {             menuid = m.menuid,             name = m.name,             parentid = m.parentid,             childmenus = createvm(m.menuid, list)         }); } 

so, how can make asynchronous using async , await keywords?
notice that, loops until children loaded completely;
is practice make async (the above code)?

unfortunately, async action filters not available (yet); see this question. can vote here mvc team add capability.

once mvc supports async action filters, use, e.g., getallasync. recursive part not require async functionality because it's not i/o-bound.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -