c# - Blocking web page in ASP.NET Web Forms with long running method -
i want show database result in gridview web page extremly slow when calling long running method.
inside gridview have template field following item template:
<itemtemplate> <asp:label id="lblnumresults" runat="server" text='<%# getnumcrawlresults(convert.toint32(eval("id"))) %>'></asp:label> </itemtemplate>
this corresponding method:
public string getnumcrawlresults(int jobid) { var task = task.run(() => utilities.getnumcrawlresults(jobid)); //this slow , blocks gui return convert.tostring(task.result); }
this database query:
public static async task<int> getnumcrawlresults(int jobid) { documentcollection collection = await getorcreatecollectionasync(database.selflink, convert.tostring(jobid)); var result = (from c in documentdb.createdocumentquery<shared.crawlresult>(collection.selflink) select c).asenumerable(); return result.count(); }
is there way assign label text when async method has finished?
thanks
is page rendering result? have impression task.wait() statement missing.
anyway, in case use ajax , knockout (or similar).