0

I am creating a cron job using .Net Core which will fetch data from API and insert data into database. Should I use ConfigureAwait(false) while calling api in asynchronous mode?

I am confused after reading article - ConfigureAwait(false) relevant in ASP.NET Core?

Since I am having console app not a UI app so Please suggest Should be go with ConfigureAwait(false) or not

5
  • 1
    ASP.NET Core does not have an AspNetSynchronizationContext (or any SynchronizationContext). As there is no context anymore, ConfigureAwait(false) is no longer needed. Commented Jun 26, 2020 at 10:57
  • But I read, ConfigureAwait (false) increase performance.I m having .Net core console app which is calling Api asynchronously Commented Jun 26, 2020 at 14:39
  • if your API is not synchronized one, you can use ConfigureAwait(false) it will not stop other Tasks being run. Commented Jun 26, 2020 at 14:49
  • Api has asynchronous methods so Do I need to use ConfigureAwait(false) or not with Api calls ? Commented Jun 26, 2020 at 15:08
  • 1
    yes, you can use that. Commented Jun 26, 2020 at 16:27

1 Answer 1

3

In short: if you are asking, then you don't need to use ConfigureAwait(false) in your application.

.NET Core framework has no SynchronizationContext. So in this contextless approach from .NET Core, the default asynchronous behavior is the same as we have, when using ConfigureAwait(false), so when an async handler resumes execution, a thread is taken from the thread pool and goes the work.

Source: https://itnext.io/a-deep-dive-into-configureawait-65f52b9605c2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.