Questions tagged [async]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
3answers
174 views

How does an hexagonal architecture help with async/await async-over-sync?

In his book "Concurrency in C# Cookbook", Stephen Cleary writes: If you can, try to organize your code along modern design guidelines, like Ports and Adapters (Hexagonal Architecture), which ...
3
votes
1answer
89 views

Difference Between AsyncResult and Task in c#

So, in C#, I understand the historical difference between the two vaguely; a Task is a newer concept and the highest level concurrency native C# offers. AsyncResult is a bit more ambiguous. For ...
0
votes
2answers
91 views

What is the best practice for incorporating asynchronous code in this case?

Context: I'm building a popup widget. The html and css files are stored in S3. I need to get those files asynchronously and then continue with the rest of the logic. In the code below, I'm getting ...
1
vote
1answer
87 views

Implementing both Sync and Async clients with DRY

I'm developing a client library. I'd like to provide both Sync and Async interfaces to endpoints on a server. They would be rather easy to implement as completely separate entities, but I would like ...
0
votes
1answer
49 views

Unit testing async tcp server

I built an async multi-client TCP server for RPC usage. It's working well but I've found it difficult to unit test certain functionality: Connect 2x clients, is client count 2 Connect 1x ...
1
vote
1answer
117 views

How do JavaScript engines convert async/await to promises under the hood?

I'm curious how the async/await syntax is converted to Promises. Maybe I'm just not thinking about it properly, but I don't know how this code would be converted to a Promise: async function myFunc(...
1
vote
1answer
113 views

How is an async stack implemented?

I am working on creating a simple VM sort of thing in JS: let sp = 0 // stack pointer let m = [] // memory initialize: sp = 0 invoke: m[sp] = m[sp - 1] // position in stack m[sp + 1] = input[m[...
0
votes
0answers
41 views

Streaming Promises in NodeJS

Imagine a typical HTTP service that does async db queries. If HTTP requests are received more quickly than the db can complete queries (such as because the db disk or network is slow), the Promises ...
1
vote
0answers
29 views

Using TPL to manage hundreds of contexts

Overview of application: A chat bot that connects via IRC, using TPL. As messages come from the socket (from .ReadAsync()), they are ultimately parsed and passed to a handler within the bot itself (...
3
votes
3answers
883 views

How to justify using await instead of .Result() or .Wait() in .NET Core?

Since the inception of .NET Core, console apps, function apps, ASP.NET etc. are not using synchronization context in async methods (so they're synchronizing straight to Thread Pool). This means that ...
2
votes
1answer
265 views

Isn't asynchronicity an implementation detail?

Consider a simple — and fake — interface: interface ISuperGetter { Super Get(); } An implementation would get some Super from RAM. On would store what it needs on disk. Yet another could fetch the ...
2
votes
2answers
118 views

Name of locking approach

I've seen this approach several times, both in async and multithreaded code. A counter is used to track asynchronous behavior or thread behavior - whenever a new action is started, the counter is ...
2
votes
3answers
498 views

Why is it necessary for every new api to be async?

I'm expressing my frustration here somewhat, but why do many new libraries only have asynchronous APIs? For example I'm creating a small utility to fetch a web page and parse some data from it. ...
5
votes
2answers
258 views

balance between UI responsiveness and avoiding race conditions

To keep scope small I will talk about UI race conditions initiated by the same user in the same app sessions. The question is general and not specific to mobile, web or desktop UI. The issue Modern ...
0
votes
1answer
136 views

I'm writing an application that needs to log error/ exception messages but should still continue execution if it not a fatal error

I'm writing an application that needs to log error/ exception messages but should still continue execution if the error is not a fatal error. I was thinking of making a method that returns a Task but ...
0
votes
0answers
24 views

Azure Service Bus Topics - Is Orchestration Needed?

We have a business process that does classic shopping/ordering. It's tightly coupled right now and does things like this: A person can view inventory. A person can create an order. An order needs to ...
7
votes
1answer
1k views

Is the C# async/Task construct equivalent to Java's Executor/Future?

I'm a long time Java developer, but with so little traffic on SE, I don't limit my viewing to any single tags. I've noticed that C# questions with async/await come up a lot, and as far as I've read it'...
0
votes
1answer
281 views

Async - why have an async for a login?

C# web scaffolding has an async call for every member. Why? For example: Async for a login call makes no sense. User has to wait for validation. What else would the app do until the application ...
2
votes
1answer
187 views

Must we define methods and async when we don't know whether the implementation is synchronous or asynchronous?

I think I know the answer to this, but it's particular enough that I don't want to go telling other people stuff until I'm 100% certain. Suppose I have a class with some dependency: public interface ...
0
votes
0answers
230 views

Using signalR for streaming alongside a microservice architecture

I have a cluster of micro services with an exposed search API serving a client app. I want to "stream" in real time the aggregated results of a complex search. The search will be kicked of by the ...
0
votes
0answers
36 views

Asp.Net Core: creating files in background

I have a web app with SPA client. When user requests a report, that request should create an excel or pdf file in background and notify user via SignalR. I guess I need to save that file somewhere ...
-1
votes
1answer
132 views

Does avoiding Promises and Async leads to clean code?

While applying for a job interview I found this line in requirements. Experience with clean code writing practices like avoiding callback hell like promises, async Does this line make any sense ? ...
-4
votes
2answers
78 views

Should I use async for networking application/library [closed]

I decided to make an application, networking application, don't know what it has to do yet but mainly it should be a cross-client kind of like framework networking application/library. Since ...
0
votes
3answers
211 views

If callback function, promises and async/await patterns all can be used to achieve asynchronous behaviour then why don't we stick to one?

As far as I have seen then async/await, callbacks and promises are and can only be used to achieve asynchronous programming. Correct? So my questions are: 1) Is it correct that the former three is ...
1
vote
1answer
416 views

Will (await method).ToList() block the thread? [closed]

I'm using a lot of async Task<IEnumerable<T>> methods and I want to stop doing this everytime to get the items as a list: var items = await AsyncMethodThatReturnsEnumerable(); var ...
0
votes
1answer
176 views

What does await do in JavaScript?

Sorry for this naive question. Reading some existing JavaScript I see a function with code like ... async function _load() { await ensureDir(path); return await readFile(filename); } ... why ...
1
vote
1answer
53 views

How to control multiply consoles from Java code?

I have Java application. I try to realize multiplayer chat with TCP protocol, but I have an issue. I cannot output all messages I get on client tier (server tier works perfectly), because I give ...
105
votes
5answers
12k views

Aren't the guidelines of async/await usage in C# contradicting the concepts of good architecture and abstraction layering?

This question concerns the C# language, but I expect it to cover other languages such as Java or TypeScript. Microsoft recommends best practices on using asynchronous calls in .NET. Among these ...
1
vote
2answers
360 views

Is it okay for async function to update a common object

I have a couple of functions, each function verifies a set of rules and updates a common object. The common object is just a container that holds a list of rules that passed or failed. I would like to ...
1
vote
0answers
81 views

Wrapper method for ConfigureAwait(false)?

Does it make sense to declare a async method as private and then create a public method to act as a wrapper that calls the private method with ConfigureAwait(false)? The intended purpose is design an ...
2
votes
2answers
158 views

Is it conventional to use both await and .then()?

I've written a bit of code that looks like this: async function fetchData() { const json = await fetch(ENDPOINT + key.key).then(data => data.json()); //Do something with the data } It's ...
19
votes
2answers
3k views

Who did async/await first?

Python added the async/await constructs in 3.5 in 2015. The Javascript community made steps towards it for a bazzillion years and finally added a very similar implementation to the draft in ES8 ...
2
votes
2answers
5k views

Better to block on async with HttpClient than use synchronous API like WebRequest?

I have been a staunch advocate of never blocking on async code. I felt it was always better to use a synchronous API than to run the less efficient state machine generated by the compiler even if ...
0
votes
1answer
220 views

Best approach for web service that calls other web services

The scenario is: client makes request to server A Server A makes potentially multiple requests to server B. Edit to clarify, server A makes the requests concurrently using Futures. Server A blocks ...
1
vote
4answers
944 views

Problem with async/await pattern — in C# and JavaScript — how to return sync value

In old-style await'less NodeJS, when you call a function that had an asynchronous aspect, you'd pass in the well-known callback which gets called when the asynchronous portion is done. This didn't ...
1
vote
1answer
133 views

sequential command processing with an async io cloud upsert

We are new to c# and still trying to grok the async idioms. We have a windows service that requires us to iterate a list of results queried from a PC database to feed the parse cloud server (which ...
1
vote
1answer
117 views

Design: HTTP and Websockets working together

I'm at a bit of crossroads here and I wanted to ask the opinion of the community. I am creating a chat application for our company. Now, like every chat application out there, the messages are saved ...
0
votes
1answer
106 views

How to statically check you didn't forget to await for an async function

A common bug in JavaScript is to forget the await keyword when calling an async function. Of course you don't always want to await, sometimes you really want to get a promise. And of course you can't ...
-2
votes
1answer
2k views

Check is finish async and await behavior

I am trying to understand the async and await.Now i want to apply async and await keyword in my current project.My process structure are: //DataAccess Private List<Users> GetAllUsers() { ......
1
vote
1answer
701 views

Multiple API calls potentially spawning multiple Websockets - Threading vs Async

I am designing a program with the flow as outlined below. Note, these are all network calls, there is no system I/O (hard drive). Initially, multiple independent API calls need to happen - they don'...
6
votes
1answer
203 views

Immediately awaiting an asynchronous call [duplicate]

While working on an inherited project, I noticed the original dev(s) created many asynchronous functions that never seem to take advantage of being, well, asynchronous. For example: // The async ...
3
votes
1answer
490 views

How can I reduce bloat in my callback based serial communication?

I'm communicating with a device that's connected to the computer via com port. The device accepts certain predefined commands in order to interact with it. I'm essentially creating a more abstract API ...
1
vote
0answers
194 views

Proper code structure for a Servlet using caching and async

I'm using an Java Servlet (with embedded Jetty, no Spring, no frameworks) and I'm adding asynchronous processing and caching to it. The exact implementation is irrelevant to this question and it's not ...
4
votes
2answers
1k views

Correct way to implement non blocking async methods in .net?

I've made the code below work and it is mostly non-blocking except where the process.start code is. However, my question is, in my winforms application is this the best way to implement the use of ...
2
votes
2answers
2k views

JS: convention to distinguish immediate vs async methods

I normally have a laissez faire attitude on method naming conventions but now I am working on a module in JavaScript that will have some methods that can return the value directly (immediate / plain ...
1
vote
1answer
3k views

Creating a (System.Threading.Tasks.)Task scheduler

I'm working on rearchitecting a game engine in which multiple concurrent scripts run in parallel threads, which unfortunately occasionally gives rise to race conditions. I'm trying to set it up so ...
4
votes
1answer
24k 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 ...
1
vote
0answers
227 views

Why are most ReactiveX implementations push-based?

Feel free to correct my history, but as far as I understand it, Rx and the Reactive Manifesto trace their roots back to C# and its Reactive Extensions, which is uses push (callback-based) messaging, ...
2
votes
1answer
1k views

Pattern for subclass overload with different arguments

I'm in the process of writing an bidirectional, asynchronous socket server and server handler. The base handler class I'm working off of is as follows: class BaseAsyncSocketHandler: async def ...
2
votes
1answer
813 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. ...