Note that there are some explanatory texts on larger screens.

plurals
  1. POAsynchronous method appears to not be fully executing
    primarykey
    data
    text
    <p>I have a process where an incoming user request to our system is being handled. I also want to add some metadata about the request to a database table without impacting the responsiveness of the main process. To achieve this I added a call to an asynchronous method like this:</p> <pre><code>public static ReturnObject ResponsiveMethod(string ip, string code) { // ... some reasonably quick code IPDetail.InsertAsync(ip); // &lt;-- call to the async method return new ReturnObject(code); } </code></pre> <p>The InsertAsync() method looks like this:</p> <pre><code> public static void InsertAsync(string ipAddress) { Action action = () =&gt; IPDetail.Insert(ipAddress); action.BeginInvoke(aResult =&gt; Log.Debug("Completed Insert"), null); } </code></pre> <p>And finally, the normally non-asynchronous method called Insert():</p> <pre><code> private static void Insert(string ipAddress) { ApplicationContextHelper.LoadApplicationContext(); var helper = new GeoLocationHelper(); var result = helper.GetDetailsFromIP(ipAddress); Log.InfoFormat("Succesfully retreived IP data {0}.", ipAddress); result.Save(); } </code></pre> <p>In my unit tests the InsertAsync() call works perfectly. Inside the method calls in Insert() there are many operations occuring which are detailed by logging, and all the expected log messages are there, as well as the final result of the result.Save() method.</p> <p>However, we have a webservice which utilizes something like the ResponsiveMethod() method above and for some reason the asynchronous calls do not complete. All of the logging in the LoadApplicationContext() method gets fired, but after that there is no log activity related to the Insert() and the result.Save() is never getting executed.</p> <p><strong><em>Revised summary question to be more concise</em></strong></p> <p>My current thinking is that the webservice has completed its task and the thread which called the asynchronous no longer exists. Would this stop the async call from completing?</p>
    singulars
    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.
    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