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

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

1 Answers1

0

More information in this question why you shouldn't use it in .net core: configureawaitfalse-relevant-in-asp-net-core

mciesla
  • 72
  • 6
  • This is the same article which I reffered in my question. It seems confusing to me. – Amit Agrawal Jun 26 '20 at 11:41
  • Oh sorry, I had to wrong read your post. What exactly is confusing for you, purpose of synchronizationcontext ? Check this explanation also from Stephen why using configure await make sens with UI [link](https://stackoverflow.com/questions/59000290/to-run-or-not-run-configureawaitfalse-with-both-services-and-activities-with-x) – mciesla Jun 26 '20 at 14:15
  • Do I need to add ConfigureAwait(false) at the time of API call or not ? – Amit Agrawal Jun 26 '20 at 14:38
  • You don't need to add it, this applies e.g to .net framework / core for console app. – mciesla Jun 26 '20 at 15:34
  • What do u mean by - this applies to .net framework/ core for console app ? – Amit Agrawal Jun 26 '20 at 15:46