vb.net - RegisterAsyncTask doesn't run asynchronous task in ASP.Net Web Forms page -
i have login page in asp.net web forms application. on successful login time-consuming database operations slowing login process, want run these asynchronously.
i trying in recommended way using registerasynctask, etc. have set @page async="true" in aspx file , implemented following code in aspx.vb file (cut down show essential elements):
protected sub btnlogin_click(byval sender system.object, byval e system.eventargs) handles btnlogin.click if loginsuccessful() dologinstuff() end if end sub private sub dologinstuff() ... registerasynctask(new pageasynctask(function() doexpensivedbcheck(userkey))) page.executeregisteredasynctasks() ... end sub private async function doexpensivedbcheck(byval userkey integer) task ... response = await task.run(function() dbservice.docheck(userkey)) if response.success andalso response.items.count() = 1 session("dbvalueforuselater") = response.item[0].whatever end if end function
however doexpensivedbcheck function never runs (a breakpoint @ start of function never hit), , session("dbvalueforuselater") never set.
i thought maybe doesn't run because login function finishes doing redirect home page of application, added page.executeregisteredasynctasks() in case, makes no difference.
interestingly if create task doexpensivedbcheck rather using registerasynctask, , wait on task application freezes, , again breakpoint in doexpensivedbcheck never hit.
does know doing wrong here?
Comments
Post a Comment