Questions tagged [async-await]

This covers the asynchronous programming model supported by various programming languages, using the async and await keywords.

Filter by
Sorted by
Tagged with
41
votes
3answers
5k views

Simon Says: “Make me a pretty game”

In Memoriam Ralph H. Baer, co-inventor of the original "Simon" game, died Saturday December 6th 2014, at 92. With his passing, this friendly little challenge inadvertently became a memorial to ...
21
votes
2answers
306 views

RubberduckParser 2.0 - Asynchronous Parsing

The IRubberduckParser interface has seen breaking changes, and now looks like this: ...
13
votes
1answer
19k views

Filtering a collection by an async result

I'm trying to do something like this: var loudDogs = dogs.Where(async d => await d.IsYappyAsync); The "IsYappyAsync" property would return a ...
13
votes
1answer
27k views

Use of Async/Await for EventHandlers

I have a MVC WinForms application. I am using Dependency Injection with Ninject as the IoC container. ...
13
votes
2answers
1k views

Asynchronous Circular Buffer in C#

Preamble I want to be able to test methods which communicate over a simple exclusively asynchronous two-way stream-like interface which may underneath use any of a number of communication methods (e....
12
votes
2answers
815 views

Stack Exchange websockets wrapper

I've been writing a small library that allows for easy querying of the Stack Exchange websockets. I'm going to add an enum to replace the manual ...
12
votes
2answers
15k views

Async/await and Task vs Task.Factory.StartNew and Result

I am working on creating some libraries for a project at work and I wanted to make sure I have this pattern correct. Assuming that the GetWidgets method is what I ...
11
votes
3answers
386 views

Async insecurities

I feel like I'm overdoing the async await stuff. I'm just learning. Maybe this isn't the best instance to be using this stuff. I have a system with sensors that detect the completion of some action....
11
votes
2answers
3k views

Async wrapper around public API

Tear it apart. I'm mostly concerned around the appropriate use of ConfigureAwait(false), and possible poor handling and duplication of the ...
11
votes
2answers
16k views

Console chat server

I'm just looking for feedback on correctness of my understanding of async/await. I'm curious about the Task.Run inside of the ...
11
votes
2answers
2k views

NewtonSoft Json.Net serialiser

I'm just starting to develop more in C# after being mainly a VB.NET developer and was looking for someone to critique my implementation of a NewtonSoft Json.Net serialiser. Can you provide some ...
10
votes
2answers
3k views

Asynchronous retry method

I've written an asynchronous retry method as an answer for this question. I'd like to get your opinion of the implementation and whether there are better ways to implement this. You could also ...
10
votes
2answers
3k views

Implementation of Asynchronous Cache

I have been attempting to implement a cache which caches the results of an asynchronous method, with the restriction that I only want that method to run once for any particular item in the cache. Many ...
9
votes
4answers
2k views

AsyncDictionary - Can you break thread safety?

This class is an Async/Await wrapped Dictionary. Of course it doesn't technically implement IDictionary, but the functionality is basically the same as an IDictionary. It achieves similar ...
9
votes
1answer
12k views

Writing highly asynchronous code

I am writing a new web service that will be performing a lot of large data load operations. To do so I am moving the data to a temporary table then merging the data in to the live data via a stored ...
9
votes
1answer
2k views

WCF using TAP without worrying about timeouts

I really like using the new TAP pattern in .Net 4.5. and I am updating some of my older projects to use it. One of my old patterns was to use EAP with WCF so I could have functions that could take ...
8
votes
3answers
249 views

Toggle any application feature ON or OFF

When testing or debugging applications it'd be often useful to be able to run it without certain features like committing things to the database, saving files, sending emails, reading files, executing ...
8
votes
2answers
2k views

Quicksort async vs serial

I am playing with async and I figured I'd write a parallel implementation of Quicksort while trying to look at various optimizations. I want to keep the generics (...
8
votes
2answers
720 views

Managing python application configuration in a key-value store

For a project we're working on, we need a central place to store the configurations for various applications (they're all headless services running in docker containers so local configuration files or ...
8
votes
1answer
1k views

Async Yield and continue on TaskPool

Using await task.ConfigureAwait(false) is a standard best practice for indicating to the compiler that the continuation does not need to be run on the current ...
8
votes
2answers
8k views

Retry loop for asynchronous HTTP requests

I've got a method that needs to PUT data to a web API. Sometimes the connection fails, so I needed a way to do retries, but if the retries fail, I still need to capture the exception and re-throw it. ...
8
votes
1answer
14k views

C# 5 Async Await .Task.Factory.StartNew cancellation

I have the async code that implements cancellation token. It's working but Im not pretty sure if this is the right way to do it so I just want feedback about it. Here is the actual code: ...
8
votes
1answer
86 views

Creating API clients that are “async agnostic”

Python3's async/await syntax is great, but it does create a divide between libraries which are async-based and those which are ...
8
votes
1answer
15k views

Async Queue Processing

I have a Queue that needs to try to process when anything updates in it (add, remove or update). However, I don't want any of the callers to wait while the ...
8
votes
2answers
2k views

Using keywords async/await in database queries (Windows Phone 8)

I have a local database in Windows Phone 8 app. The app includes a lot of queries to the database and I don't want bad effect on the responsiveness of UI. For ...
8
votes
1answer
377 views

Looping until browser document is ready

I made a do...while loop in order to wait for the web browser to load completely in order to enter username and password. I don't know whether this impacts the ...
7
votes
3answers
200 views

Notifying the UI that Issues Were Found

Our Rubberduck VBA IDE Add In does some static code analysis, and then reports all of the found issues back in a gridview. This analysis can take a long time for larger projects and the UI appeared to ...
7
votes
3answers
505 views

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

My code is a variant on the Visitor Pattern and a "leaky bucket" variant. The goal is pretty straightforward: the "bucket" will collect a specified number of items (say, for example, 500) and then ...
7
votes
1answer
4k views

Async TCP client/server

I'm working on a simple async TCP client server application, i'd like my network code to be reviewed. I really feel that I'm doing something wrong, especially in receiving code. Interface for client: ...
7
votes
2answers
81 views

Cancellable UI loader

I'm playing with async/await, but I have yet to discover a standard method to safely cancel an intensive task. I have tested the following, and it works exactly as intended, though I remain unsure if ...
7
votes
1answer
808 views

Buffered queue for logging

I'd like to use a buffered queue for logging via a WebAPI that handles multiple applications. This helper should reduce the blocking that occures due to logging. I've been experimenting with a ...
7
votes
1answer
80 views

Simple integration of async and tkinter in Python

I've been a fan of coroutines and asynchronous programming for a while, and I recently took a trip down memory lane to when I was using Python's tkinter module for ...
6
votes
3answers
2k views

Async method with three internal tasks

Consider we have three different database stores which we want to find an Id which is unique in all this three. I mean if we query first data store and we find that id. It's over and there is no need ...
6
votes
2answers
9k views

Task timer async

I had been still using BackGroundWorker and decided to learn async Task. My test project is a simple timer that can be canceled. The target project is to read instruments with a delay for sampling. ...
6
votes
3answers
2k views

Downloading blobs asynchronously

We have a working implementation that is doing I/O operations, returning data from blobs in an async/await manner from Azure Blob Storage. ...
6
votes
2answers
9k views

Async and error-handling

I need to delete a file when an error occurs during loading it. It is not allowed to perform async operations in a catch block. This has lead me to writing the following code: ...
6
votes
2answers
126 views

Network helper class with retry logic on failure

I wrote an helper class which allow me to request the body content from a site that is created by AJAX, for doing so I'm using <...
6
votes
3answers
2k views

ToPaginatedListAsync<T>

I'm using this method and I would likely have a code review. Also, I have one concern and is that source.Count() is executing synchronously and I don't know how to ...
6
votes
2answers
10k views

Listen to multiple RabbitMQ queue by task and process the message

Single app which listen to multiple RabbitMQ queue and process the message. This is working fine but not sure this implementation is right one or I am missing something. Implementation is inspired ...
6
votes
1answer
74 views

Custom HttpClient implementation for third part usage with sync/async calls

I'm doing an implementation of HttpClient that is built in a NET Standard project, which will be used as a base to build and process JSON requests/responses for a third part REST API. Client is built ...
6
votes
1answer
3k views

Display Loading Text with Spinner in Console

Here is my approach to creating a loading text spinner in the console. I did what I thought was best in designing the class, which means there is probably a lot of room for feedback. The class is ...
6
votes
1answer
886 views

Embedding an RSS feed into a page after it's already loaded

I'm working on reworking our website from a WYSIWYG editor to MVC. I'm all right with server side code, but complete rubbish when it comes to client side Javascript, so I'd appreciate any/all feedback....
6
votes
1answer
15k views

WPF async await TcpClient/TcpListener sample

I want to build a robust and highly scalable client server system. Here what I have so far(an echo server as my base of implementation) My Server ...
6
votes
1answer
8k views

Use and understanding of async/await in .NET 4.5 +

I am just about to embark upon a massive job of multi-threading a cost-engine. I could use TPL of which I am very familiar, but would like to leverage the async/<...
6
votes
1answer
655 views

Priorizatable command queue

This code consistently executes commands with a given priority. How can I to improve it? ...
6
votes
1answer
8k views

Async SerialPort Wrapper

I've been working with the SerialPort class for a while, trying to figure out the best way to work with it, and especially adding support for Async-Await in C#. I ...
6
votes
1answer
152 views

Enumerating smart card terminals asynchronously in ViewModel constructor

I started a project the other day and started going down the path of using async and await as I have never used it before and it seems like a good match. The app that I'm making is a WPF solution ...
6
votes
0answers
3k views

Socket application using TPL

This is an application I wrote that allows multiple TCP clients to share a single TCP connection to a remote server (hosted project, and a demo). Traffic generated by the server is forwarded to all ...
5
votes
1answer
25k views

Starting a fire and forget async method

Sonar/FxCop are telling us that we shouldn't use void async methods. That's ok. This is the current implementation: ...
5
votes
1answer
28k views

Async/await in Parallel.ForEach

I have a Timer: var QueryReportTimer = new Timer(QueryReportTimerCallback, null, TimeSpan.Zero, TimeSpan.FromSeconds(15)); ...