c# - Web API - Accept incoming POST, pass off operation and close connection ASAP -


i have interaction server makes post calls web app. problem have server making calls tends lock records app go update.

so need accept post, pass off thread/process in background , connection closed possible.

i've tried things like:

public ihttpactionresult post(mytestmodel passin) {  if (modelstate.isvalid) {    logger.debut ("conn open);     var tasks = new []    {       _mymethod.passoutoperation(passin)    }    logger.debug ("conn closed");    return ok("ok");    }  return badrequest("error in model"); } 

i can tell amount of time inbound requests take connections aren't being closed down be. in testing 3 consecutive posts web app.

looking @ logs have expected entries connection open , closed @ top of log. closed connections @ bottom, after operations trying pass out have completed.

has got tips?

thanks in advance!

for interested solved problem.

i'm using:

var tasks = new thread(() => {   _mymethod.passoutoperation(passin); }); tasks.start(); 

the reason code stopping because passing httpcontext.current.request.userhostname in other method. out of scope when setup new thread. i've since changed , declare variable outside of code block create new thread, , pass in via methods constructor e.g.

_mymethod.passoutoperation(passin, userhostname);

hope helps in future!


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -