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
1
vote
0answers
71 views

Refactoring try blocks with async/await

I have two functions which I would like to simplify. They have largely the same logic, but one is asynchronous and uses one await in a try block. I'd like to have the logic in one place, but could not ...
1
vote
0answers
86 views

SelectAsync With Max Degree Of Parallelism

I have been looking for the best approach to creating an extension method that would give me the ability to select in a linq query using async/await with a max degree of parallelism. I'm aware that ...
3
votes
2answers
80 views

Adding a cancellation token to TcpListener.AcceptTcpClientAsync()

There is no facility in TcpListener (or for that matter Socket) to close a listening socket that is waiting for a connection without throwing an exception. After running up a test bench with 8 ...
4
votes
1answer
74 views

Python: Asyncio object-oriented style

I'm seeking a review of some code I've written for a small personal project. The project is not yet mature enough for any domain specific details to be of concern - but I'm happy to provide further ...
1
vote
0answers
64 views

Handle aws lambda function containing multiple axios call

I have written an aws lambda function in NodeJS which has 2 async axios call. ...
5
votes
0answers
71 views

TPL Dataflow - Timer Action Block

I'm new to TPL Dataflow and was looking for an action block to basically push an object on a timer - specifically to produce heartbeats on every interval. I was unable to find anything out of the box ...
3
votes
0answers
155 views

Hosted service for queuing and running tasks in parallel in ASP.NET Core

I am attempting to construct a background service for an IIS-hosted ASP.NET Core project that basically queues tasks and runs them, and I decided to go with the ...
0
votes
1answer
169 views

Cancel Long Running Query using Cancellation Token AND SqlCommand.Cancel()

I need to be able to cancel a long running query programmatically through our application. The code below will kick off a long running query and give control back to the main thread. At any ...
0
votes
1answer
80 views

Mixing Async and Sync in same HTTP request ASP.NET Core C#

Is it bad practice to mix async and sync call in same ASP.NET core API call? For example, in following code method CropBlackBroderOfAnImageAsync is an async method....
3
votes
2answers
79 views

Cleaner Way to Structure Asynchronous Code

The purpose of the code is to allow the user to select directories that will be crawled recursively in order to find particular files or file types to analyze en masse. The thing to bear in mind is ...
1
vote
0answers
72 views

Async scheduler that executes commands multitthreaded

I have made a multithreaded command runner that works, just wanted to share the code and see if you guys can see any pitfalls. Comments are not part of actual code ...
3
votes
0answers
114 views

Python AsyncIO pipeline

I wrote a small snippet to implement asyncio Pipeline - object that connects together Layers, and lets them create and pass ...
3
votes
1answer
60 views

Token Bucket context manager for rate limiting async calls

I've written a class that implements something akin to the token bucket algorithm so that I may rate limit aysnc HTTP requests made from my application. The code works but I'm still not sure if it ...
2
votes
0answers
35 views

Passing JSON files through an API - node async

I am writing a small program which reads some JSON files, passes the content to an API, then saves the response in some more JSON files. A pretty simple task, and the code works fine, but I have been ...
4
votes
0answers
46 views

Data encryption / decryption on Node.js

I've implemented my first data encryption / decryption methods on Node.js. Although it might look similar to hundreds of sample implementations available online, I'm curious to get a feedback. I'm ...
8
votes
1answer
406 views

Operation logger

GitHub, NuGet This component traces execution in a logical order instead of chronological as everybody else :) For example, the following code: ...
4
votes
1answer
948 views

Asynchronous parallel ForEach implemented using Task.Run

I wrote a simple implementation of aysnc parallel.ForEach( ... ) All it really does is create a list of tasks and wait for them all to complete and aggregate the ...
2
votes
1answer
48 views

Python task runner with asyncio

I'm trying to a write super simple task runner with asyncio. Basically, my goal is to run 100 requests to google as tasks, whilst also being be able to handle tasks being added at a later time. <...
6
votes
0answers
107 views

Single-threaded fully asynchronous server, with a SocketSelector that dispatches events

I need a fully asynchronous single-threaded server written using .Net Core. Searched for options and, surprisingly, did't find any. So I decided to write a simple prototype. Borrowed idea from python'...
3
votes
1answer
81 views

LINQ for extracting N bottom items (async streams)

source.Bottom(n, x => x) should be the same as well known LINQ source.OrderBy(x => x).Take(n) but is more memory/run-time ...
7
votes
2answers
349 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
1answer
89 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 ...
10
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 ...
1
vote
1answer
87 views

Async Tcpwriter and Reader

I currently have a class that I want to serialize/deserialize messages sent to this socket. My plan was to use Task.WhenAny() to monitor 2 tasks (Either watch ...
2
votes
0answers
63 views

Await data coming from an event [closed]

This is a USB related question, but the problem is not USB specific. When reading data from a USB endpoint, there are two patterns I am concerned with. Request/Response like HTTP (done over the Bulk ...
3
votes
0answers
149 views

Example Multiple Async Await Calls Javascript

I need to make an unknown number of api calls, up to 5 max probably. But most samples I've seen show only a couple of async calls so are effectively hard coded to the number of calls being made. This ...
13
votes
2answers
2k 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....
1
vote
0answers
66 views

Custom hook to handles async calls with loading and error state?

I have built this hook to handle async calls. It should manage state for the loading and ...
1
vote
0answers
13 views

Functions to handle async calls and also handle loading and error status in React component

I've got the following component structure: Component hierarchy: <AdminBlogPostContainer> <AdminBlogPostPage> <BlogPostForm> ...
5
votes
2answers
161 views

Async concurrency prevention class

Because I'm quite naive regarding C#'s Task Asynchronous Programming and concurrency in general, and because it's so difficult to test, I'm concerned about the safety of this code. It's likely that ...
5
votes
1answer
178 views

Scraping an parsing jockeys data using Task.Run

I started to have HUGE doubts regarding my code and I need some advice from more experienced programmers and architects. On the button click, the application runs a method, that is running a ...
1
vote
0answers
28 views

DB2 monitor using idb-connector

Monitors DB2 for changes in table data. It doesn't take any actions with the data just yet, only checks to see if new data is available every 2 seconds. ...
5
votes
1answer
147 views

SQS subscriber pattern in background service

I have the below code to pull messages from a FIFO SQS queue. Using the while (IsRunning) loop makes me feel to question the code design. Is there a pattern I am ...
5
votes
2answers
128 views

Tcp server messenger awaiter in f#

Hi I have a simple tcp server, and that server receives messages with specific length so basically i need to wait for TcpClient to fill buffer with that amount of data, and it works. But I am not ...
4
votes
1answer
100 views

Wrap a callback method in an awaitable method

I'm using a .NET library which uses a pre-async/await type of asynchronicity. That is, it provides asynchronous (non-awaitable) method with a callback parameter. I'm trying to write awaitable ...
8
votes
3answers
254 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 ...
7
votes
1answer
364 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 ...
3
votes
2answers
222 views

Named Semaphore with async calls

I have multiple distinct processes that need to access external resources that are rate limited. The processes are all async in nature and run in different applications. In times past I would just ...
3
votes
1answer
301 views

Implicit Async and none async event handlers

I have implemented a event aggregator for our backend. ...
3
votes
0answers
56 views

Communication with interactive program using ChildProcess

There is an interactive program, namely Microchip Debugger (Later called MDB), which I want to communicate with from NodeJS program. You can think about it as any console-based debugger - they all do ...
1
vote
0answers
137 views

Putting a Queue Between HTTP Request/Response

We currently have two legacy systems: the Consumer and the Worker. These systems are massively complex in ways that are not important to this review, but it is enough to say that a large-scale re-...
4
votes
1answer
2k views

Safely executing background tasks in parallel in ASP.NET Core

Context and initial idea I'm trying to teach myself the CQRS and Event Sourcing patterns by developing a simple ASP.NET Core application, loosely following Greg Young's example CQRS implementation on ...
4
votes
1answer
541 views

SemaphoreSlim extension method for safely handling cancellation and disposal

I have often found myself using a try {semaphore.Wait()} finally {semaphore.Release()} pattern when using a semaphore, so decided I wanted to try and write an ...
3
votes
1answer
80 views

Separating Fetch Calls and using in Promise Chain

I´m currently working on a small microservice application, which will in it´s simplest form just receive a Request from a Formular and and based on containing information perform several other Server-...
1
vote
3answers
108 views

Class constructor with async properties set from poke-api

So, this is for a clicker game I'm trying to build with Pokémon data drawn from the PokéAPI. Since I'm using Vue.js for the project, ...
0
votes
1answer
47 views

Displaying multiple objects on map and calculating distances using google api

I am quite new to Javascript. For a school project we wrote a website that displays the user's location on a google map alongside with some objects such as vehicles or passengers. I rewrote my code ...
4
votes
2answers
505 views

Parallel FTP client

I was given the task to download files for a FTP server. The download should be fairly fast. 15 parallel connections can be used. I have used FluentFTP as the ...
3
votes
0answers
83 views

Scheduler built with observables v3 (follow-up) - now testable

This is a 2nd follow-up to my previous one about a Scheduler built with observables. Although the last one was working correctly, it was only possible to see this ...
3
votes
1answer
35 views

JavaScript that deletes everything inside a folder on Box.com

I just finished a simple script for Node that will delete all the folders and files inside a specified folder ID through Box's API. It works by getting a list of items inside a folder, then generating ...
1
vote
2answers
92 views

Get an array of currency exchange prices based on asset

Function getMarkets Makes a call to get Cryptocurrency Exchange data based on asset (USD, USDC, USDT) It calls the endpoint 3 times to return 3 arrays which are then returned to the callee. I have ...

1 2 3 4 5 6