Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple asynchronous method calls to method while in a loop
    primarykey
    data
    text
    <p>I have spent a whole day trying various ways using 'AddOnPreRenderCompleteAsync' and 'RegisterAsyncTask' but no success so far.</p> <p>I succeeded making the call to the DB asynchronous using 'BeginExecuteReader' and 'EndExecuteReader' but that is missing the point. The asynch handling should not be the call to the DB which in my case is fast, it should be afterwards, during the 'while' loop, while calling an external web-service.</p> <p>I think the simplified pseudo code will explain best: <br> (Note: the connection string is using 'MultipleActiveResultSets')</p> <pre><code>private void MyFunction() { "Select ID, UserName from MyTable" // Open connection to DB ExecuteReader(); if (DR.HasRows) { while (DR.Read()) { // Call external web-service // and get current Temperature of each UserName - DR["UserName"].ToString() // Update my local DB Update MyTable set Temperature = ValueFromWebService where UserName = DR["UserName"]; CmdUpdate.ExecuteNonQuery(); } // Close connection etc } } </code></pre> <p>Accessing the DB is fast. Getting the returned result from the external web-service is slow and that at least should be handled Asynchnously. </p> <p>If each call to the web service takes just 1 second, assuming I have only 100 users it will take minimum 100 seconds for the DB update to complete, which obviously is not an option. <br> There eventually should be thousands of users (currently only 2).</p> <p>Currently everything works, just very synchronously :) <br> Thoughts to myself: <br> Maybe my way of approaching this is wrong? <br> Maybe the entire process should be called Asynchnously?</p> <p>Many thanx</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload