Questions tagged [asynchronous]

Asynchronous programming is a strategy for deferring operations with high latency or low priority, usually in an attempt to improve performance, responsiveness, and / or composability of software. Such strategies are usually employed using some combination of event-driven programming and callbacks, and optionally making use of concurrency through coroutines and / or threads.

Asynchronous programming is a strategy for deferring operations with high latency or low priority, usually in an attempt to improve performance, responsiveness, and / or composability of software. Such strategies are usually employed using some combination of event-driven programming and callbacks, and optionally making use of concurrency through coroutines and / or threads.

Asynchronous programming is used in many situations:

  • handling user input in UIs and games,
  • processing network traffic,
  • performing disk I/O,
  • batching work,
  • and more.

Asynchronous programming models can aid in software composition in many languages (notably languages where functions are first-class types) and APIs providing callback-based completion messaging. Proper use of this programming methodology can improve throughput and improve responsiveness by reducing total latency of job batches when executed in parallel. This approach can also result in an increase in system throughput at the cost of increased operational latency resulting from deferred processing.

50995 questions
13
votes
1 answer

rxjs use async/await in map Rx.Observable.range(1, 5).map

I want get a list from rxjs using async/await. What should I do? function getData(num){ return new Promise((resolve, reject)=>{ resolve(num + 1) }) } async function create(){ var list = await Rx.Observable.range(1, 5).map(async…
Moon
  • 259
  • 1
  • 2
  • 12
13
votes
4 answers

Is there default way to get first task that finished successfully?

Lets say that i have a couple of tasks: void Sample(IEnumerable someInts) { var taskList = someInts.Select(x => DownloadSomeString(x)); } async Task DownloadSomeString(int x) {...} I want to to get the result of first successful…
Sic
  • 287
  • 3
  • 7
13
votes
5 answers

In Node.js design patterns unleashing zalgo why is the asynchronous path consistent?

In the great book i'm reading now NodeJs design patterns I see the following example: var fs = require('fs'); var cache = {}; function inconsistentRead(filename, callback) { if (cache[filename]) { //invoked synchronously …
Jas
  • 14,493
  • 27
  • 97
  • 148
13
votes
2 answers

Angular2 refreshing view on array push

I can't seem to get angular2 view to be updated on an array.push function, called upon from a setInterval async operation. the code is from this angular plunkr example of setInterval: What i'm trying to do is as follows: import {View, Component,…
Omer Kushmaro
  • 195
  • 1
  • 1
  • 6
13
votes
1 answer

How to render partial on the same page after clicking on link_to with AJAX

I have a list of customers. Every customer has a link, which links to the customers page and displays his data. I want to link to partial rendered on the same page below the table of customers. On initializing the "page" with the table, a blank page…
mahu
  • 297
  • 1
  • 3
  • 14
13
votes
1 answer

How do I load page javascript after async loading of my manifest file

I am trying to convert my app to asynchronous javascript loading with: <%= javascript_include_tag "application", async: true %> The problem is that any page-specific scripts are being run before Jquery is loaded asynchronously. How can I defer…
Abram
  • 39,950
  • 26
  • 134
  • 184
13
votes
2 answers

How do I ".Wait( )" on a ConfiguredTaskAwaitable?

Given the following extension to prevent Tasks from blocking the UI Thread ( probably not the exact correct terminology but whatever ) : public static ConfiguredTaskAwaitable DontBlock( this Task T ) { return T.ConfigureAwait( false ); …
Will
  • 3,413
  • 7
  • 50
  • 107
13
votes
1 answer

Async await and parallel

I'm bit confused on how async/await can work as parallel so I made a test code here. I try to send 6 task I simulated with a list. Each of this task will execute 3 other subtask: You can copy/paste for test. using System; using…
Zwan
  • 632
  • 2
  • 6
  • 23
13
votes
2 answers

What are the scalability benefits of async (non-blocking) code?

Blocking threads is considered a bad practice for 2 main reasons: Threads cost memory. Threads cost processing time via context switches. Here are my difficulties with those reasons: Non-blocking, async code should also cost pretty much the same…
Winston Smith
  • 153
  • 1
  • 8
13
votes
2 answers

React Native Synchronous Secure Random Number Generation

I'm trying to generate keypairs in a React Native project. The key pair generation tool relies on the crypto module's random byte generation, which produces a buffer of a specified lengths with random byte values. In order to use the crypto module…
arik
  • 28,170
  • 36
  • 100
  • 156
13
votes
3 answers

Pass value from internal to external function - Cannot save password

I try to hash passwords with crypto and I cannot save them in the database. I have node.js 4.2.3 express 4.13.3, and my database is PostgreSQL 9.1. The field is character varying (255) and is named pswrd. This is my code: var tobi = new User({ …
slevin
  • 4,166
  • 20
  • 69
  • 129
13
votes
1 answer

How to use ReadDirectoryChangesW() method with completion routine?

I want to use function ReadDirectoryChangesW() in asynchronous mode with I/O completion routine supplied. The question is I don't know how to retrieve the exact information about the change in the completion routine (a CALLBACK function).…
user26404
  • 1,371
  • 4
  • 27
  • 38
13
votes
1 answer

SSH.Net Async file download

I am trying to download files asynchronously from an SFTP-server using SSH.NET. If I do it synchronously, it works fine but when I do it async, I get empty files. This is my code: var port = 22; string host = "localhost"; string username =…
spersson
  • 538
  • 1
  • 8
  • 19
13
votes
2 answers

Wait Firebase async retrieve data in Android

I need to store the result of FireBase getValue method that is async by his own. I can't use something like "onPostExecute()" and, for my purpose, i can't execute all my operation "into onDataChange()" because i need some references in future time…
13
votes
1 answer

Memory leak in F# async recursive call

I'm confused why this function shows memory constantly increasing let rec startRead1() = async { do! Async.Sleep 1 System.GC.Collect() let mem = System.GC.GetTotalMemory(true) printfn "%d" mem do! startRead1() …
lobsterism
  • 3,469
  • 2
  • 22
  • 36
1 2 3
99
100