52 votes

Async method with three internal tasks

Short and clean using null-coalescing operator: ...
YuvShap's user avatar
  • 545
32 votes
Accepted

Use of Async/Await for EventHandlers

The things to consider when it comes to async event handlers are: Exceptions thrown for the handler might be rethrown on the UI ...
svick's user avatar
  • 24.3k
24 votes

AsyncDictionary - Can you break thread safety?

The reason why there is no async API for a dictionary is, that all operations on a dictionary are so fast, that there is no need for asynchronicity. For concurrent scenarios there is the thread safe ...
JanDotNet's user avatar
  • 8,538
21 votes
Accepted

Async method with three internal tasks

Use the return pattern: ...
A Bravo Dev's user avatar
15 votes
Accepted

Async/await in Parallel.ForEach

Is it ok to have an async void method? Referencing Async/Await - Best Practices in Asynchronous Programming As already stated in the OP async void should be ...
Nkosi's user avatar
  • 3,236
14 votes
Accepted

Using async / await with dynamic import() for ES6 modules

Approach 2 does not work because accoring to MDN: import '/modules/my-module.js'; Is how you import a module for Import a ...
Taki's user avatar
  • 608
13 votes

AsyncDictionary - Can you break thread safety?

Threading Design Your implementation has a very intrusive lock for all read and write operations, using the SemaphoreSlim with max concurrency 1. ...
dfhwze's user avatar
  • 13.9k
12 votes

AsyncDictionary - Can you break thread safety?

It's pretty hard to break something that uses a global lock around everything. So this seems pretty thread-safe. But that doesn't answer the question of why you'd want to use this. Asynchronous ...
Voo's user avatar
  • 525
11 votes
Accepted

Pass Async function to new Promise constructor

There's simply no reason to wrap your existing promise with another promise and no reason to use await or async here either: <...
jfriend00's user avatar
  • 3,948
11 votes
Accepted

Task timer async

Initial observation is that you should avoid async void like private async void start() { //... } except for event ...
Nkosi's user avatar
  • 3,236
10 votes

Asynchronous Circular Buffer in C#

Quick Review An API like this, dealing with thread-sensitive operations, requires time and effort to test and review rigorously. When I will find this time, I will do a thorough review. But here are ...
dfhwze's user avatar
  • 13.9k
10 votes

Asynchronously scrape fabric information

While you can put request parameters in the URI directly, it's usually neater to pass those using the params argument of ...
Sara J's user avatar
  • 3,432
9 votes

Download Images as fast as possible

Just a few quick remarks (for now): vbNullString is a remnant of VB6 (which I think would be under the ...
Mathieu Guindon's user avatar
9 votes
Accepted

AsyncDictionary - Can you break thread safety?

If you modify the AsyncDictionary while enumerating its keys/values it throws InvalidOperationException (if the backing ...
Johnbot's user avatar
  • 2,974
8 votes

Network helper class with retry logic on failure

Just wanted to add that you may want to consider using Polly instead of rolling your own retry mechanism - this is a library built specifically for this kind of retry mechanism (as well as many more ...
rob.earwaker's user avatar
8 votes
Accepted

Operation logger

One drawback I can think of this way of logging is that (correct me if I'm wrong) it is lazy. That's to say, until the root Op object is ...
JAD's user avatar
  • 2,909
8 votes
Accepted

Simple async task scheduler

No way to stop the cycle. The standard with TPL is to use the CancellationToken. Even if it is not need now, which I don't know why, it would be easier in the future if it supported it. For example ...
CharlesNRice's user avatar
  • 4,343
7 votes
Accepted

Concurrent/parallel ForEachAsync - proper handling of exceptions and cancellations

Test Case 2 Correct, but only if those exceptions are thrown asynchronously. See (3) below. Correct. When you do await task.ContinueWith(...), you are no longer ...
Ohad Schneider's user avatar
7 votes
Accepted

Network helper class with retry logic on failure

After our initial comment-review-update sequence/loop there is not much left for a review but still, one more thing. You can get rid of the if entirely when you add ...
t3chb0t's user avatar
  • 44.3k
7 votes

Asynchronous and recursive word square generator in C#

Algorithm It is always better to start out with a good decent algorithm before we try to optimize by vectorizing etc. Let’s look at what we need to do. Iterate through all the words (List<string&...
jdt's user avatar
  • 2,362
6 votes
Accepted

Async TCP client/server

Async/Await Async/await's main advantage is that you no longer need to use ContinueWith() to chain tasks, making the code much cleaner. Your code seems to more ...
D. Jurcau's user avatar
  • 3,010
6 votes
Accepted

Visitor Pattern/Leaky Bucket variant implementation to run an operation at a certain interval

First of all, IMHO the code is well written and has some meaningful comments. Visitor Pattern Actually, I am not sure if the OverflowingBucket has something to do ...
JanDotNet's user avatar
  • 8,538
6 votes
Accepted

Downloading blobs asynchronously

There is never a need to do this: return Task.Run(() => GetDataAsync()).Result; Why start a new task and then synchronously wait with ...
RobH's user avatar
  • 16.9k
6 votes
Accepted

Parallel and Sequential array looping with async/await

JavaScript's execution model My understanding is that the first one is parallel because the await applies to each invocation of the async lambda that is passed to map. This is not quite right ...
ComFreek's user avatar
  • 751
6 votes
Accepted

Implementation of Asynchronous Cache

The way your code is today this should work fine. But if you ever decide to add a RemoveItem method you can have issues. Since you are checking if the key exist ...
CharlesNRice's user avatar
  • 4,343
6 votes

Connect to MySQL and fetch a list of customers asynchronously using C#

In Get() you do not need to wrap the call to GetAllCustomers() into a Task because it's ...
Adriano Repetti's user avatar
6 votes

Task timer async

You're doing all your work in the 'code-behind' rather than a seperate viewmodel class, but for a project this small doing that 'right' would double the amount of code 😀 ...
Kelson Ball's user avatar
6 votes
Accepted

ForEachAsync extension method (a way to run an async operation on each item of a sequence in parallel)

Rather than writing something custom, you could use the TLP Dataflow library. ...
Matt Cole's user avatar
  • 948
6 votes
Accepted

Mini HttpClient json post by Action parameter

Great job. Here are some minor notes though. In newer versions of C# you can leverage async Main in order not to wait for your test method. ...
Bohdan Stupak's user avatar
6 votes

Scraping an parsing jockeys data using Task.Run

if (TaskCancellation == true) { break; } ...
Peter Taylor's user avatar
  • 24.1k

Only top scored, non community-wiki answers of a minimum length are eligible