Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How should I free my threads in async action method with async db calls?

$
0
0

for example

public async Task<string> MyAction(var parameter)
{
  if (condition)
  {
    await DbHelper.AddItem(parameter); //Dapper async query
  }
  else if (otherCondition)
  {
    await DbHelper.UpdateItem(parameter);
  }
  else
  {
    await DbHelper.RemoveItem(parameter);
  }

  // return string after some arbitrary logic
}

In one of my views I have an interface that uses jQuery.post() to post to this Action.  The user may call this action many times while at this view endpoint.

I keep running into this : InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

So basically I'm wondering what I can do to free my threads after an await call?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>