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
2
votes
1answer
9k views

Custom HttpClient Wrapper

I need to wrap httpClient because I'm using a custom token provider. I will use this code with asp.net mvc to communicate with our webApi2 server. ( Using webApi2 with directly from ui with angularjs ...
2
votes
1answer
962 views

Safe async API code

I'm pretty new to async/await and I want to ensure that the code I've written is going to be safe and not cause any deadlocks. The RestClient in the code will be ...
2
votes
2answers
338 views

Class for easier to read IProgress<Class> handling (Version 2.0)

This is an update to my question Class for easier to read IProgress handling and includes the suggestions from @svick, with one exception. It was also suggested to change the setter for ...
2
votes
1answer
1k views

Listening for several connections in an async method

Is there a better way to structure a method that returns a task that queues several inbound socket connections? ...
2
votes
1answer
71 views

C# Async/Await networking server

I made a simple async networking server and I'd like to get some input on the code, whether things can be done better and whether the code is stable (able to hold more than 1000 connections without ...
2
votes
1answer
42 views

Chart of answered CR posts percentages over time - Part 2

I created a graph to show the change in the percentage of questions answered over time and the first version fetched data from chat transcripts using PHP. The sub-domain I have registered for my ...
2
votes
1answer
77 views

Simple but important function to check and retry given action's result

What I'm trying to achieve is Given a predicate function and an action which returns the object to check, check predicate, retry and fail after numTries .. or success . Purpose of this function ...
2
votes
1answer
619 views

Reading multiple CSV files and asynchronously update SQLite

My console app needs to read several big CSV files to update its data, which are stored in a SQLite database. I am new to C# and would like to know if there are ways to improve this sample code I ...
2
votes
1answer
864 views

Ensuring no race conditions in my concurrent/parallel ForEachAsync method

Hopefully the final chapter of my ForEachAsync code review. The original question was the starting point and the second question contained modifications suggested ...
2
votes
1answer
161 views

Performance of an OLX crawler

I'm learning concurrency and asynchronous programming in C#. For a better grasp on the matter I'm trying to create an OLX Crawler. My issue here is the performance: It takes roughly 159 minutes to ...
2
votes
1answer
1k views

Buffered asynchronous writer

Imagine I have connection in which I have to write numbers, represented by this contract: ...
2
votes
1answer
336 views

A utility class for running up to two Tasks serially, where the last task to be queued “wins”

Edit: Use cases for this class - I needed this class in the case where I had processes I needed to execute (in the form of tasks - they were all asynchronous) that I needed to issue to a UI control ...
2
votes
1answer
2k views

Await and interactive Android ADB shell

I'm writing an app to let me interact and debug my android over USB using the android SDK and the ADB command. I create a Process with redirected input and output streams and basically run "ADB shell"...
2
votes
0answers
71 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 ...
2
votes
0answers
33 views

Porting python's 'with' construct to TypeScript

Now that async generators are available in the platforms I care about, I figured I'd try porting Python's ingenious with construct to JS as a utility. My first stab ...
2
votes
0answers
253 views

MVVM Databinding, Commands, Async - MVVM.Light [closed]

I'm new to C#, WPF and MVVM and I don't want to make common mistakes right from the beginning and get used to them. I already read some similar questions on best practices for WPF/MVVM but none of ...
2
votes
0answers
50 views

Conditional AsyncLock implementation

I have a case where I match data from DB by the various filters. Until the match is updated in the DB, I don't want to accept requests for matching with the same criteria, as this could produce ...
2
votes
0answers
227 views

React widget to display, sort and search remote data

I've created a React widget that pulls data on crypto-token pairs from a remote API and makes that data sortable by headers and searchable. You can view a demo of it here. Is this a maintainable way ...
2
votes
0answers
161 views

Server app: pinging up to 500 clients asynchronyosly

TCP/IP server which controls up to 500 clients. There's a list of added computers and the server gets this list, selects computers which are not already connected and ping them using host name. ...
2
votes
0answers
663 views

Async/await Mysql wrapper

I used MySQL, but it was inconvenient so I made a wrapper. It works, but I'm unsure if there are any issues. Used node module - mysql2, bluebird sqlWarpper.js ...
2
votes
0answers
180 views

asyncio with live update and abort capabilities

This is my first shot at asyncio. I'm looking for any pointers you might have. Especially: Are there any race conditions? This code doesn't scale as expected. In ...
2
votes
0answers
308 views

Promise-based unit tests using Pub/Sub

I've recently been learning and adopting Promises, async/await, and unit testing for my JavaScript server project. I just finished a unit test for some pubsub code that was more convoluted than ...
2
votes
0answers
152 views

Establishing a TCP connection with async & await

I'm not really super experienced async/await and working with tasks, so I thought I'd ask for some other opinions. I'm working with code written by someone else that establishes a TCP connection. It ...
2
votes
0answers
123 views

Multithreaded download of images from a spreadsheet

I've been wanting to go async with my HTTP calls but all the methods I tried have not worked, so I resolved to implement this as a task and then improve upon it. This is what I've come up with so far....
2
votes
0answers
437 views

Implementing TAP around WMI

I'm trying to improve my skills with the Task-based Asynchronous Pattern (TAP), by writing simple task-based wrappers around some WMI methods: ...
1
vote
2answers
1k views

Parallel process interest in C#

In web api controller: I am a newer in parallel and Async&Task programming. Need someone help me code review. ...
1
vote
1answer
4k views

Calling synchronous code in asynchronous method

I'm implementing an interface with the async method Execute. In this I need to call some synchronous code. (removing an item from a dictionary). What would be the ...
1
vote
2answers
1k views

Asynchronous lookup over HTTP and checking the status

For some reason declaring ApiResult before checking if the answer is in a correct status doesn't look good. I wonder if there is any better way to check the status ...
1
vote
2answers
270 views

Asynchronous Queue

implemented a basic Asynchronous Queue so, that I can do await queue.push(item); const item = await queue.pop(); basically I'm trying to convert a synchronous ...
1
vote
1answer
333 views

Timer class implementation

I have made a timer class: The timer should call an async method and wait between two calls. I want to wake up the timer to skip the wait period. When I dispose the timer from outside the timer I ...
1
vote
2answers
515 views

Running tasks in parallel

I've just started writing asynchronous methods for the first time having watched some tutorials. I have a method where I run two tasks in parallel (...
1
vote
3answers
85 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, ...
1
vote
1answer
195 views

Return combined DTO from async controller

I have an asynchronous controller. It is supposed to make a couple async calls then return combined data from then as one DTO. ...
1
vote
1answer
2k views

Testing async method call from constructor

I have a project where I want to build a more sophisticated ToDo list - basically a personal project management system. I'm just starting out with the project, and I'd like some feedback on whether my ...
1
vote
1answer
506 views

Lazy Init if the Items property is null

I was refactoring a quite large WPF project and I found some pieces of code where it can leads to error. Ive got some services in the form ...
1
vote
2answers
3k views

UI error display window with task async in WPF

I am new to async and was wondering if any improvement can be made to the solution I put together from scattered information on the web. The following (working) code shows how a button press runs ...
1
vote
1answer
3k views

Work with nested task [closed]

I have Client and Server classes. The Server return a ...
1
vote
1answer
4k views

Simple async/await progress bar

In researching the new .NET Async and Await keywords in .NET 4.5, I created a simple example showing how to update a progress bar and a label while an async function is running. I also included how to ...
1
vote
1answer
1k views

Extension method to to run any async method synchronously

Sometimes I need to call async code from a synchronous method. This leads to repetition in code to wait for the task to complete, then ensure that the expected ...
1
vote
1answer
1k views

Executing multiple async methods synchronously without throwing

I have a following task: execute multiple asynchronous methods synchronously and always execute them all, even when one of them throws. Rethrow thrown exceptions if any occured only after all tasks ...
1
vote
1answer
1k views

Converting a method to async

I have a method that calls a "bridge" for TraderMarketInfo. When info is received, it checks if info IsSet and raises an event. ...
1
vote
1answer
1k views

Starting a process asynchronous

For executing a Process I've created an separate class which binds the possibilities together, for example reading output, start as Admin, catch Exceptions and also start all this asynchronous. Are ...
1
vote
1answer
51 views

Asynchronous Stack

implemented a basic asynchronous stack so, that I can do. await stack.push(item); const item = await stack.pop(); basically I'm registering listeners when ever i'...
1
vote
1answer
129 views

Async database helper function in TypeScript

I have made an async function in TypeScript that responds to Events and returns an object with methods that return a promise. I ...
1
vote
1answer
2k views

Async structure build (example for simple chat bot on Discord.NET)

I'm making a simple scheduler for a bot on Discord.NET and I'd appreciate some help with proper async structure of this since most of DNet is async-based. There are 2 components to this: a ...
1
vote
1answer
109 views

Making JSON requests to fetch relationships asynchronously

I would like to refactor the fetchRelationships function to use async await. I am not sure what the best way is to do it as this code contains nested .then at ...
1
vote
1answer
137 views

MUD Telnet game

I'm new in JS and my daily job is PHP, so I decided to do simple MUD Telnet game to practice my JS skills. The idea was to use async/await to do Telnet server code that seems synchronous at first ...
1
vote
2answers
498 views

Processing files retrieved through FTP in parallel

I am busy creating a file processor that needs to get some files from an Ftp client download the file and save the data into the database. I have a two part question. How can i refactor the code to ...
1
vote
1answer
78 views

Socket.ReadPacketASync

I'm working with TCP Sockets and I've build a simple packet struct that turns it into a datagram protocol. I've created a class which returns "promise" Tasks for Packets. Packets are very simple, they ...
1
vote
1answer
725 views

JavaFX await implementation

I'm debating trying to take a crack at getting something similar to C#'s async-co-routine like nature over on JavaFX. This is technically feasible since the Quantem toolkit exposes the ...