Is this C # waiting for too much?

I understand carving to a certain extent, but in practice I have little experience. Looking at this code that I maintain, it seems like AWAIT is not doing any good. All calls to this method are made via AJAX and only happen when the user clicks on the export link. Since the method does nothing, I don't see any benefit to AWAIT and will instead imagine that it actually introduces some overhead. I also believe that all other users clicking on export will enter this method as their stream, right? So it can only be useful if one user quickly clicked on export. Thank.

[PreventLogging]
    [HttpPost]
    public async Task<JsonResult> GetActivityReportCallsAsync([DataSourceRequest] DataSourceRequest request)
    {
        try
        {
            var result = await GetAllCallsAsync();
            return Json(result.ToDataSourceResult(request));
        }
        catch (Exception exc)
        {
            return JsonShowMessage(false, ServerMessageType.Error, exc.Message);
        }
    }

      

+3


source to share


1 answer


it seems like AWAIT is not doing any good

You might want to take a look at the async

MSDN MSDN article
. In it, I list a number of common misconceptions about what async

will or won't do for your queries.



So async

/ await

on ASP.NET is for scalability and assumes you already have a scalable backend. This will not make any single request run faster or return earlier or anything like that.

+8


source







All Articles