asynchronous - Async, Azure and program flow -
i have searched forum problem didn't find suited, im having problem program flow.
i have mobileservice on azure has question table, app has main menu , quiz button takes user quiz page, on quiz page have start quiz button shows first question in list.
this code im using questions database, placed in pages constructor , when user presses quiz button there delay in page opening isn't bad not long wait, few seconds, there better way this?
task<imobileservicetable<question>> getdatafromdatabase = new task<imobileservicetable<question>>(getquestions); getdatafromdatabase.start(); questionlist = await getdatafromdatabase;
in same function have code modifies start quiz button isenabled attribute. stops quiz going forward unless data has came through server, not working time , start button isenabled set true , nullreference mobileservicecollectionview questionlist though task has completed.
task<bool> assigndata = new task<bool>(assigntabletoitems); assigndata.start(); startbutton.isenabled = await assigndata;
any on appreciated.
thanks
you shouldn't have create new instance of task<t>
query database (you haven't provided definition of getquestions
used in first code snippet, can't tell whether code doing it's supposed to). you'd typically table appropriate type mobileserviceclient
object, , query on it:
var client = new mobileserviceclient(appurl, appkey); var table = client.gettable<question>(); var questionlist = await table.tolistasync();
regarding second code snippet, without definition of assigntabletoitems
it's hard know you're intending code do.
Comments
Post a Comment