Implementing Retry Logic with Backoff and Cancellation in C# Asynchronous Tasks
I have a service which runs as a background job. It’s duty is to try and hit some external service for some external update. Now, I am to attempt retrying an HTTP request against the service for a specified number of times. Ultimately, after the third try, I am to backoff for a few minutes, and try one more time. The service should return on failure of the fourth try.
Why does Meziantou.Analyzer suggest me to await GetManifestResourceStream?
Meziantou.Analyzer tells me to add an await in front of GetManifestResourceStream with info MA0042
What is the current guidance for async/await APIs to replace .NET events?
Consider the case of a library intended for use with other projects, which could be console applications, other class libraries, or applications with a UI. This library allows the user to send commands to and receive responses from a remote end point, but can also receive event messages from the remote end point. It is a valid use case that the user may send a command in response to a remote event. The transport mechanism uses async/await
methods for transferring data to and from the remote end (e.g., using a WebSocket). In a “classic” .NET application, I might design an API like the following:
Can you use async await safely inside an async void event handler in c#?
I have an async void
event handler that must stay “fire-and-forget”. Sadly, it contains logic that may throw an exception. I was thinking of putting the actual business logic inside an async Task
that is awaited inside the async void HandleMessageSafely()
method that only has the responsibility of catching and logging errors.
Async/Await exception handling confusion
I’m trying to understand async/await in .net8, especially exception handling and I’m running into some confusion, especially regarding the documentation as while it specifies some of the approach it doesn’t give enough examples for me to understand what’s happening.
When to use `async Task` versus `Task`?
I’ve been programming async C# for years, but today was the first time I noticed a method that returns a Task
without using the async
and await
keywords.