Questions tagged [asynchronous-programming]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4
votes
1answer
943 views

Is it generally bad to await async operations in background processing (not needing the result)

So I've been working with background processing and event-driven systems, namely Azure WebJobs and ServiceBus. And while there is extensive use of async/await programming, I'm always wondering if it ...
0
votes
1answer
1k views

How to avoid synchronous communication between microservices

Let's say we're talking about a webshop. Microservice 1: Manages products and their prices Microservice 2: Responsible for payment and checkout. If a user wants to pay for a product, the payment ...
0
votes
1answer
147 views

How do I not lose the "reactive" nature of my services, simply because one of the services isn't reactive?

I've lately been very interested in reactive microservice design with streaming and event-driven architectures. When one writes (i.e., manages) services, this paradigm works extremely well by simply ...
4
votes
2answers
1k views

CQRS async query from command handler

In a CQRS/async microservices context, I have a command handler e.g. SendOrderConfirmationEmailCommandHandler implemented in a communications service. This depends on information from the orders ...
0
votes
2answers
2k views

When to check if the user is logged in?

I have an app with an optional login where some functionality requires the user to login. When checking if the user is logged in I use a framework that runs an async function that requests an access ...
3
votes
1answer
160 views

Design for avoiding concurrent calls to an interface implementation

The application I'm developing requires that some data is obtained through different channels. As this is a network process, I have decided to use async programming. I have designed the following ...
2
votes
1answer
67 views

How do I approach polyglot plugins for asynchrous python applications?

I've been looking at ways to let my app's users write plugins for it. However, to give them more options, I decided to implement a polyglot plugin system. From the engineering perspective there are ...
1
vote
1answer
251 views

How do I set up short-lived queues?

This scenario seems pretty ordinary, and yet, strangely, messaging systems (like Google Cloud PubSub and Task Queues and ActiveMQ) do not seem to support it -- they assume that topics/queues are long-...
0
votes
1answer
1k views

An elegant way to detect the end of an asynchronous recursive file search?

Given a recursive subroutine in single threaded environment which starts numerous asynchronous I/O operations and registers callback functions for each of them. This callbacks will be called on the ...
-1
votes
2answers
712 views

Straight line coding - How multithreading simplify asynchronous workflow?

Java author mentions: Threads can simplify the development of complex systems by turning complicated asynchronous code into simpler straight-line code. Again the book says: Threads make it easier to ...
3
votes
1answer
377 views

Composable asynchronous programming in Java without too much GC

Assume I'm writing a library in Java for performing network calls. I want it to be efficient for cases like highly loaded reverse proxies etc (10s to 100s Krps coming in and out; client requests ...
1
vote
1answer
1k views

Best practice to callbacks in OOP (JavaScript)?

For anyone who uses callbacks, how do I approach it when the method is an asynchronous setter? Here's an example class API { constructor() { this.token = null; } refreshToken(callback) ...
4
votes
1answer
25k views

Correct usage of async/await and Task.Run()

I am developing an application that will read excel files from disk and then process tests based on the data in the files. In order to keep the user interface from locking up when loading files and ...
5
votes
4answers
3k views

How do I know if my async function is truly asynchronous?

I'm writing a function in the node.js-style asynchronous way, but how do I know if these functions are truly asynchronous, i.e., that they run in parallel and not sequentially? Here is my code (...
3
votes
3answers
859 views

Is there a pattern for a chain of asynchronous calls, followed by a cleanup?

I have two asynchronous tasks that need to get completed - say they're "make a pie" (make) and "bake a pie" (bake). I also need to cleanup after everything's done - "clean the kitchen" (cleanup). bake ...
4
votes
3answers
2k views

Providing a non-blocking IO API in a C library

I am working on a C library (SlipRock) for interprocess communication. The library currently exposes a simple, blocking API. This is easy to use, makes misuse (relatively) difficult (this is C after ...
6
votes
3answers
1k views

Why do many languages semantically distinguish "async" functions from "non-async" ones?

I've seen this in C#, Hack, and now Kotlin: await or an equivalent operation can only be performed in special "async" contexts. Return values from these are, to borrow Hack's terminology, "awaitable" ...
4
votes
2answers
246 views

Design of asynchronous component

I'm trying to design an asynchronous component. Requirements on this component are : Component might receive events at any point in time Component might start a long-running operation and wait for ...
1
vote
0answers
81 views

Capturing keyboard events for a limited time

I'm trying to code a kind of simple video game where there are two kind of players: Human Players: They enter an keyboard input CPU Players: A random input is calculated For Human Players there is a ...
4
votes
1answer
134 views

Building objects from multiple async server queries

I'm building a system that uses objects that are built using multiple Async queries to a remote server (Firebase) and queries to a local DB. How should I design a module to generate these objects? ...
3
votes
1answer
114 views

How to document logical proofs against race conditions?

Specific Background I'm writing a library to extend the async backbone of a language with cooperative multitasking. (The language is Hack, but C# also implements async-await with Task, if the concept ...
2
votes
1answer
858 views

Task Parallel Library Console Application Design - How do I lock a thread to a specific context?

I'm currently developing an application which relies on multiple sockets listening for chat messages. When the messages come in, they're passed off to a bot that's associated with their channels. ...
2
votes
1answer
66 views

Asyncronous processes competing for the output area

You enter the URL in the address string of your browser. It takes long time to appear in the client area. You are bored and type another address instead and click enter. Which page will be rendered in ...
21
votes
3answers
43k views

Calling multiple async services in parallel

I have few async REST services which are not dependent on each other. That is while "awaiting" a response from Service1, I can call Service2, Service3 and so on. For example, refer below code: var ...
2
votes
1answer
785 views

Animations and React -- is it bad practice to mix them?

I have been in arguments with programmers that mixing elements with animations and react is very bad practice, and that all animations should be in a style sheet because that is something ...
2
votes
3answers
119 views

Synchronising results from asynchronous tasks

In Android, I rather frequently need to get results from more than one service that utilizes an asynchronous callback pattern and I want to know if there's a better way to handle this pattern than ...
7
votes
1answer
433 views

API design: stream objects vs. functions vs. messages

I'm designing API for a python library that accepts asynchronous input and produces the asynchronous output: various signals come in, and various signals are generated in response (there's no one-to-...
3
votes
2answers
301 views

What to call a method that calls itself asynchronously?

In UI-related code, I often end up writing a construct like this: function doItOnceAndRepeat() { if (!stillNeededToDoIt()) { return; } doIt(); runLater(doItOnceAndRepeat, 1000)...
6
votes
1answer
5k views

Does omitting await keyword once in the call stack break the asynchronous behavior of the whole stack?

Call stack may contain several methods returning Task. If all of them are decorated with async, the flow of execution is quite simple. However, what if one of them is not awaited - are other method ...
1
vote
2answers
1k views

Why are Promises not "awaited" by default?

In the latest version of languages like TypeScript or ECMAScript you can use async/await constructs to write code that combines the clean structure of synchronous programming with the performance ...
1
vote
0answers
62 views

How to display a very delayed success message after async method call in WinForms after Form is closed

The users are on a Windows Form where they fill out a fax cover sheet and hit Send. The remote fax service takes anywhere from two seconds to two minutes to return a result (long timeout). By that ...
0
votes
1answer
799 views

Android Activitiy and Service Sync

I've looked for the solution of my problem but I've failed in finding a suitable answer. I've been trying to develop an Android application with heavy asyncronous networking capabilities. The problem ...
3
votes
1answer
350 views

What is the functional programming method for combining two "streams" of data?

I'm trying to figure out what the appropriate way to deal with this problem is in a functional way. I'm assuming there's a functional data structure or technique that will make this easy to handle. ...
-1
votes
2answers
142 views

Designing an application with safe paralleled tasking

The title may have been a little vague... I am working on a piece of software that is designed to perform one task. I would like this task to work in parallel, allowing for multiple asynchronous ...
1
vote
1answer
666 views

Multi threaded and event driven [closed]

I got this problem in an interview and want to confirm multi threading adds no value here. Case: You are writing an agent to buy stocks. The agent is initialized with a set of stocks to buy when ...
1
vote
1answer
467 views

Need Async/Await equivalent for BackgroundWorker

Given the following code in the DoWork() event of a BackgroundWorker object, how can the concept be converted to the Async/Await model? I wish to execute multiple downloads simultaneously in order to ...
0
votes
1answer
107 views

What is the difference between running two blocks of code on the same thread and running them on two synchronous threads?

Suppose I have two blocks of code, A and B. A is to be executed before B. As I understand, I can do one of two things: 1) Put B in a separate thread that is to be executed after A's thread, or 2) Put ...
58
votes
8answers
9k views

Are events only used for GUI programming?

Are events only used for GUI programming? How do you handle in normal backend programming when something happens to this other thing?
2
votes
2answers
3k views

Using asynchronous calls for heavy IO operation: How to prevent crushing the CPU?

I have an application that reads a large binary file (1GB on average) and compresses into a bzip2 archive. I started out at first compressing these files synchronously, as I didn't want to impede ...
21
votes
3answers
8k views

API Gateway (REST) + Event-Driven Microservices

I have a bunch of microservices whose functionality I expose through a REST API according to the API Gateway pattern. As these microservices are Spring Boot applications, I am using Spring AMQP to ...
3
votes
1answer
1k views

Using and designing asynchronous APIs with naturally synchronous parts

I've been programming for a long time, but very rarely with anything asynchronous (and not often with anything to do with multithreading, either). Mostly for the fun of it, I'm writing a program to ...
0
votes
0answers
472 views

Is there a ddd approach for sending events about embedded aggregate views

I'm investigating how we can notify UI/async clients (websocket) about an update which happened in an embedded view. Let me elaborate... We currently have a newsfeed where NewsItem is an aggregate ...
0
votes
0answers
57 views

Handling error with Promise

I'm writing a small application in TypeScript that has to do some asynchronous operation and I'm doing it with Promise and async/await sugar. But my problem do not rely on the particular language or ...
0
votes
2answers
729 views

Method to mask variable names in C++ files (cpp, h) and create an intermediate API?

I have a project which involves using C++ files along with an API on a local PC to communicate with a remote server app, and for sake of maintaining a semblance of non-disclosure with any hired ...
5
votes
1answer
3k views

Is there use case for implementing a callback if a future is returned?

If I have function which returns a future, is there any reason to also include a callback where the callback is simply called right before the future completes? The only advantage I can think of ...
9
votes
1answer
3k views

"Reactive programming is programming with asynchronous data streams." is this true?

I was reading about Reactive programming, and came across this article The introduction to Reactive Programming you've been missing with the quote I put in the question title: Reactive programming ...
0
votes
4answers
2k views

Callbacks without concurrency? [closed]

To sync on the terms I will first give my perspective on what a callback function in the simplest possible terms: A callback function is a function that is executed as a response to a certain ...
1
vote
3answers
1k views

Use case for async/await?

Background Most of the applications that I write are hour long sequential tests for electronic equipment. The equipment under test has a specification that is a state-machine that looks like... Get ...
3
votes
1answer
438 views

Trying to understand some async/await behavior

I was working on a bit of code for a personal project, when I came upon the need to generate checksums on large amounts of files. First off let me say I already solved this problem ideally using ...
2
votes
3answers
156 views

What is the right architecture for scalably scheduling and managing frequent periodic asynchronous?

I have built a setup which solves my problem, but I've pretty much just hacked it together by reading AWS docs and trying things out, so I want to see if there is a better way. For the purpose of ...