Skip to main content

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
0 votes
2 answers
7k views

Set Label content and make it disappear after 5 seconds

Let's say I have a label and a button. If I click the button, the label is set to some text, say "hello, world!", and after 5 seconds, it should disappear. Easy enough, right? I have the following ...
adyavanapalli's user avatar
2 votes
0 answers
382 views

AsyncLock implementation for JS

I made an AsyncLock implementation due to a comment on Hacker News saying JavaScript was missing such a necessary idea. I honestly am not terribly familiar with Threaded programming and the concept of ...
John's user avatar
  • 384
2 votes
0 answers
265 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 ...
magu_'s user avatar
  • 938
0 votes
1 answer
1k views

Return a Promise for a JSON POST

Given this method, we don't know which syntax is the more appropriate. ...
BlackHoleGalaxy's user avatar
2 votes
1 answer
497 views

Parallelly resizing mutiple photos

This code snippet is supposed to utilize async await to resize a photo file into multiple sizes in parallel. I just want to know if I am doing it in the right way. I would love to hear some ideas on ...
iampervaze's user avatar
3 votes
1 answer
483 views

AsyncObjectPool<T>

I've recently needed a class to help me manage a pool of re-usable objects. It's my first time delving into the async/await side ...
Jason Larke's user avatar
3 votes
1 answer
61 views

Depleting certain data from a webpage asynchronously

I've written a scraper in python using asyncio library to exhaust the name, address and phone number of all category from a webpage. Few days back, when I created a scraper to parse a webpage ...
SIM's user avatar
  • 2,501
0 votes
1 answer
4k views

Async task post method WebAPI controller

I have a post method in an WebAPI2 controller. I just want to make sure that everything I have done is correct. I want to create a new task run the method asynchronously and return a message. ...
user148014's user avatar
4 votes
1 answer
3k views

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

I am connecting with a database and returning values from a Web API controller. For better performance, I am doing it completely asynchronously with a new task. Am I doing it the correct way? Am I ...
srv8's user avatar
  • 41
4 votes
2 answers
3k views

Fetch an array from API endpoint in async function

I've been studying javascript for the love of it, I'm currently learning how to use async functions and my code actually works, but I know there is always room for improving. I'm open to any help ...
ricardoNava's user avatar
14 votes
2 answers
7k 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 ...
bornfromanegg's user avatar
4 votes
2 answers
17k views

ReadAsync: Continuously reads stream and spits out Packets

I am creating a server client app where after the connection is done, the server and client will send packages back and forward. The Stream can be a NetworkStream or SslStream. I have created a Async ...
Eric S.'s user avatar
  • 41
3 votes
1 answer
983 views

Recursively find TypeScript files imported/exported from an entry point

I'd like to know what's the best practice as functional programming in JavaScript to work with arrays and passing them as an argument to a recursive function that may run itself within its branch. In ...
PRAISER's user avatar
  • 151
8 votes
2 answers
1k 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 ...
ChrisWue's user avatar
  • 20.3k
7 votes
1 answer
2k 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 ...
t3chb0t's user avatar
  • 44.3k
1 vote
1 answer
501 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 ...
SebastianStehle's user avatar
0 votes
1 answer
1k views

async/await IIFE

Would anyone be so kind to assist me if I’m ‘cooking’ async/await a right way? I attend to return an express response once promise to DB resolves. ...
Coderbit's user avatar
  • 143
1 vote
0 answers
3k views

Navigate a WebBrowser control asynchronously

I wrote a little method to navigate a WebBrowser control asynchronously and returns DocumentResult, yet i wanna know if this is ...
Ricky Spanish's user avatar
5 votes
1 answer
2k views

Batch processing requests

I have a service which receives many requests and I am trying to optimize it by aggregating requests in batches and then processing batch which is much quicker than processing requests one by one. ...
vlada's user avatar
  • 51
3 votes
1 answer
6k views

Running async tasks and cancelling after a timeout if necessary

I have a few tools that run automatically. In those tools I usually run two to six jobs that run asynchronically. Sometimes when there is more data then expected or to prevent them from running ...
t3chb0t's user avatar
  • 44.3k
2 votes
0 answers
867 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 ...
odigity's user avatar
  • 121
3 votes
2 answers
102 views

Display information returned from feedservice and SQL querys on WPF window

The class file below handles the display of information to a WPF window. In its current state it works except for the fast it takes 2 minutes for the window to open because of the SQL query's and ...
Michael's user avatar
  • 31
5 votes
1 answer
2k views

Checking HTTP headers with asyncio and aiohttp

This is one of my first attempts to do something practical with asyncio. The task is simple: Given a list of URLs, determine if the content type is HTML for ...
alecxe's user avatar
  • 17.3k
2 votes
1 answer
1k 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 ...
nico9T's user avatar
  • 225
3 votes
0 answers
258 views

Minimal Async Web Server in Rebol 2

I'm building a rudimentary web server in Rebol 2. I'm trying in particular to understand the flow and logic behind the asynchronous aspects of the TCP scheme. As far as I can understand it, you ...
rgchris's user avatar
  • 489
3 votes
2 answers
3k views

Scraping HTML via async controller & classes + HTML agility pack

I've developed a simple application to grab golfer index scores from a website that has no API. The application works but is very slow, with 6 users that require updating takes 60 seconds. I've tried ...
jon.r's user avatar
  • 419
6 votes
1 answer
4k 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 ...
D. Ben Knoble's user avatar
1 vote
1 answer
165 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 ...
user avatar
1 vote
0 answers
3k views

Indefinite loop in a coroutine vs. re-scheduling a coroutine

I recently started working with asyncio and coroutines. I have a coroutine that runs every 0.25 seconds to print "running ..." on screen indefinitely. When the script receives a SIGTERM or SIGINT it ...
Daniel's user avatar
  • 111
0 votes
1 answer
1k views

WPF async ObservableTaskQueue class

I'm currently working on a WPF application, making calls to various web APIs. Thus, I'm looking after a special observable tasks queue: Progress value must be available Tasks (API calls)/seconds must ...
Profet's user avatar
  • 103
6 votes
1 answer
21k views

Parallel and Sequential array looping with async/await

Are these good implementations of parallel and sequential "extension" methods, and do they accomplish what I think they do? My understanding is that the first one is parallel because the await ...
Dave Cousineau's user avatar
3 votes
1 answer
1k views

Try again, and again, and again... but not too often because the potatoes won't grow

The delay sequence has been fixed so I can move to the next step which are the Retry and Breaker. (Just ignore the console ...
t3chb0t's user avatar
  • 44.3k
2 votes
1 answer
2k 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 ...
Terry's user avatar
  • 229
7 votes
3 answers
4k 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. ...
Mihai Neagoe's user avatar
5 votes
1 answer
6k views

Concurrent/parallel ForEachAsync - proper handling of exceptions and cancellations

I've created an asynchronous parallel ForEach mechanism so I could enumerate an enumerable by N degrees of concurrency and process an action for each item. ...
Terry's user avatar
  • 229
3 votes
1 answer
4k views

Creating a concurrent/parallel ForEachAsync that can fail immediately or wait until enumeration is complete

I needed an asynchronous parallel ForEach mechanism so I could enumerate an enumerable by N degrees of concurrency and process an action for each item. Searching ...
Terry's user avatar
  • 229
2 votes
0 answers
172 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 ...
DaveDev's user avatar
  • 121
7 votes
3 answers
738 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 ...
EJoshuaS - Stand with Ukraine's user avatar
5 votes
1 answer
1k views

Download Images as fast as possible

I have a spreed sheet and its something like 550+ columns and I need to pull URLs from it. Previously I was using LinqToExcel when the sheet was less than 255 columns a recent update has produced this ...
BanMe's user avatar
  • 75
2 votes
0 answers
130 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....
BanMe's user avatar
  • 75
3 votes
1 answer
2k views

Client/Server, Asynchronous ping-pong exchange

I'm mainly wondering about whether or not I have used the (TAP) async/await pattern correctly. I get a bunch of these warnings, "Because this call is not awaited, execution of the current method ...
Dan's user avatar
  • 31
1 vote
1 answer
977 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 ...
advapi's user avatar
  • 165
7 votes
1 answer
5k 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: ...
HardLuck's user avatar
  • 175
3 votes
1 answer
3k views

A Switch for async function invocations

I have implemented a simple "switch" function - that switches and invokes an alternate function, if the function that is to be invoked fails or timesout. This code will be later employed as part of ...
coder_bro's user avatar
  • 419
4 votes
1 answer
1k views

Task-Based Overlapped IO In .NET

I've been working wrapping the Windows API's Overlapped methods in the more usable Task based approach. There isn't much information out there on doing this, so I've been flying blind apart from a few ...
Benjamin's user avatar
  • 209
4 votes
1 answer
11k views

WPF - Run an async Task with DispatcherTimer

I have a small application that checks some system status and display it details. I have the following code which is working. But I want to make sure it's optimal: ...
idris's user avatar
  • 43
28 votes
1 answer
76k views

Use of Async/Await for EventHandlers

I have a MVC WinForms application. I am using Dependency Injection with Ninject as the IoC container. ...
MoonKnight's user avatar
2 votes
1 answer
197 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 ...
Zroq's user avatar
  • 121
3 votes
2 answers
1k views

TPL Async Await in Console Apps

I just picked up Async Await and I am trying to use Async Await in Console App along with TPL for querying webservices. The code works fine and I am able to get the speed using HttpClient and async. ...
user_v's user avatar
  • 131
1 vote
2 answers
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. ...
YUu's user avatar
  • 33

1
3 4
5
6 7