Tags down


ConfigureAwait(true) in library

By : Edemar Modesto
Date : September 16 2020, 01:00 AM
Hope this helps ConfigureAwait is a decision that only needs to be made per function. If a specific function needs to return to its context, then it should not use ConfigureAwait(false); otherwise, it may use it. Whether the functions caller needs a context is immaterial; when its caller awaits, it can decide for itself whether to use ConfigureAwait(false) or not. So option (3) should never be used.
You can go with option (2), and that's the one that I would choose at this time. ConfigureAwait(false) does have some benefits. However, there is currently an ongoing shift in opinion on this matter, largely driven by the fact that ASP.NET Core does not have a context (so ConfigureAwait(false) is a noop, and people don't like it cluttering up their code). For myself, I still use ConfigureAwait(false) in library code, but some other developers have removed ConfigureAwait(false) from their libraries completely. This is equivalent to your option (1). Either of those options would work; if performance isn't a concern, it just comes down to preference.
code :

Share : facebook icon twitter icon

when should I use ConfigureAwait(true)

By : Meme Lord
Date : March 29 2020, 07:55 AM
like below fixes the issue One possibility I can see is if you're writing code in a library and you want to allow your callers to decide whether it's appropriate to continue on the original context1 (although I'd usually argue for never continuing on the original context from within library code)
Your caller will either pass a bool parameter or set some configuration value, and so you will not know until runtime what the correct argument value is.

Is it advantageous to use ConfigureAwait(false) in a library that directly returns a Task from a call to another library

By : Chuck Layne
Date : March 29 2020, 07:55 AM
may help you . No, don't do this.
Since you're not using await, you're not supposed to configure for it in advance. It's the responsibility of the caller of your library to do the ConfigureAwait call. And the caller may well want to call ConfigureAwait(true) instead of ConfigureAwait(false) - you don't know that.
code :
async Task<Something> DoSomethingAsync()
    return await DoSomethingElseAsync().ConfigureAwait(false);
Task<Something> DoSomethingAsync()
    return DoSomethingElseAsync();

Web API - ConfigureAwait(true) not working as I thought

By : Sebastian G.
Date : March 29 2020, 07:55 AM
To fix this issue
When an asynchronous handler resumes execution on legacy ASP.NET, the continuation is queued to the request context. The continuation must wait for any other continuations that have already been queued (only one may run at a time). When it is ready to run, a thread is taken from the thread pool, enters the request context, and then resumes executing the handler. That “re-entering” the request context involves a number of housekeeping tasks, such as setting HttpContext.Current and the current thread’s identity and culture.

ConfigureAwait(true) is working only on 4.6

By : Flashenry
Date : March 29 2020, 07:55 AM
To fix the issue you can do That is a new feature in the .NET Framework 4.6
See: Task Class (System.Threading.Tasks)

Is ConfigureAwait(true) always get back to the orignial thread, even when the callee method does ConfigureAwait(false) i

By : Okta Riveranda
Date : March 29 2020, 07:55 AM
it fixes the issue Re : Doesn't .ConfigureAwait(true) mean that flow will return to the same thread once the await completes?
No, in most cases, there is no guarantee. Stephen Cleary has a definitive answer:
code :
public static async Task Main(string[] args)
    // Can await asynchronous tasks here.
Related Posts Related Posts :
  • Array of ints - does not exist in the current context
  • How to return a dynamic object list from web api in c#
  • Converting sql to LINQ C#
  • Why is the CS0120 error showing up? I cant figure it out
  • Is there way to use extension methods to achieve below implementation in C#?
  • Two constructors in one class C#
  • C# remove line using regular expression, including line break
  • WCF Enum By Value Surrogates to support dynamic enums
  • Call c# executable in c++ managed and run asynchronously
  • C# lambda filter by condition in sublist
  • c# deserialization exception InvalidOperationException: <ArrayOf xmlns=''> was not expected. How to import array f
  • How to write window event log by order
  • To obtain date value from the SQL Server database using linq in C#
  • Biometrics Fingerprint is giving somebody else's information
  • How can I make my app send out notifications when it's loaded but not running in the foreground?
  • Where do i put the } symbol?
  • How do I use AOP for Blazor assemblies
  • Multiple entities to same DbSet
  • Async task deadlocks if task is extracted first
  • finding a substring in a list of strings
  • How to initialize a scoped injected class in ASP.NET Core involving asynchronous calls
  • C# worker service vs windows service
  • C# Protobuf Deserialization
  • Is it possible to get only initialized properties in a C# class
  • Get list of values used on a `where` clause of a SQL Query
  • Remove redundant String from array string
  • How to Convert the Following Xml to C# Object
  • Take class which implements interface
  • Using Autofac with ASP.Net Core 3.1 generic host "Worker Service" application
  • Combine first character with every other of a word
  • when "nwserver.exe" stops, it doesn't launch the second program in c#
  • why Firebase in C# form app not realtime?
  • Add double quotes to variable name for MS Deploy code in c#
  • Can you always Invoke instead of checking InvokeRequired?
  • C# out of scope objects not getting collected
  • Input for block breaker game
  • Can .net micro framework project upgrade to .net core?
  • Callback from C++ to C# using SWIG
  • Memory leak in .NET Core 3.0 app when using NLog or Serilog
  • Using StringBuild to change string to lowercase only for uneven positioned letters
  • A possible object cycle was detected which is not supported
  • Using Where clause in Group Join
  • Console.ReadLine() not working in VS Code, writing a code in C#
  • Expression instead of statement
  • HttpClient static with new
  • FileSystemWatcher does not notify on deleting the path directory itself
  • Disable AutoDetectChanges on Entity Framework Core
  • C# casting to parent still running child methods
  • How to solve error does not contain a definition for - new to C#
  • Trying to create Login System in C#
  • Entity Framework is not able to pull specific record by its ID in C# back end
  • Referencing a .Net Core 3.1 project from a .Net Standard Class Library
  • Infinite loop on my unit test is confusing me
  • Web Api - body data serialize issue occurs null values to unused DTO properties
  • How does TcpClient improve on raw Sockets?
  • How can hashset.contains be O(1) with this implementation?
  • How to sort strings alphabetically that separated by special character like comma in asp.net C#
  • Get Except of multiple nested dictionaries using LINQ expression
  • How to unit test private method in .Net Core application which does not support "PrivateObject"
  • Why do I get "The type is defined in an assembly that is not referenced" in this case?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk