When to use async and await?

Asked

Viewed 21 times

-2

Good morning,

I started working with c# and . Net recently on a micro service architecture. I noticed that all methods (controllers, services and repositories) use async/await. No criteria. According to what I read, it’s asynchronous programming, it makes sense to use it in controllers, for example ?

It makes sense to use async in an API controller ?

For example

    [HttpPost("bulk/list/profiles")]
    [ProducesResponseType(typeof(IEnumerable<Profiles>), 200)]
    public async Task<IActionResult> GetBulkUsers([FromBody]string[] userIds)
    {
        var result = await _profileManager.GetBulkUsersProfile(userIds).ConfigureAwait(false);

        return Ok(result);
    }

Thank you.

  • https://answall.com/search?tab=votes&q=await%20async%20%5bc%23%5d

  • Thanks for the link, I changed the question to make my question clearer.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.