Questions tagged [async-await]

This covers the asynchronous programming model supported by various programming languages, using the async and await keywords.

0
votes
2answers
33 views

debugging async C# in visual studio; breaking on exceptions as expected

I'm struggling to figure out how to use visual studio to debug async code sanely, since it's not breaking where I want it to. For example, in this code: using System; using System.Threading.Tasks; ...
1
vote
1answer
26 views

React async / await is not waiting in the calling function - but the called function is executing correctly

I have an image upload method on my react component that calls a helper method in a separate helpers.js class to handle the actual upload, so that I can re-use that method elsewhere in my application. ...
0
votes
3answers
21 views

Catch block is entered before “await Promise” is resolved

Trying to save a camera snapshot in chrome. I have working code using Promise.resolve().then().catch() method, and I want to convert to async/await. Original code: function onSnapshotButtonClick() { ...
-1
votes
1answer
40 views

Waiting for all jobs to be finished with async await

I'm trying to understand the usage of async-await in C#5. If I have 2 jobs started in a method, is there a best way to wait for their completion in C#5+ ? I've done the example below but I fail to see ...
2
votes
1answer
22 views

Function not returning pg-pool results

I'm trying to use pg-pool to query a Postgresql database. And then export this data to a Node.js express rest API. Here's my exports function. exports.getDashboard = function(req, response, next) { ...
-1
votes
1answer
29 views

Why does awaiting a function cause an “Invalid left-hand side in assignment”?

Why does await specifically cause an invalid left hand assignment? for(let b = 0; b < uniqueMenuItems.length; b++ ) { uniqueMenuItems[b] = uniqueMenuItems[b].replace(/®.*/, ""); ...
0
votes
0answers
34 views

Running multiple async readers are not running asychronously

In the below code I'm trying to run three queries asynchronously. When they start it's definitely asynchronous in that it says 'start sync1, start sync2, start sync3' and this is immediate. When I run ...
0
votes
2answers
29 views

How should I handle exceptions for API data requester?

How should I handle this exception for API data requester? The Dostuff1,2,3 is 3 different functions that retrieves data from an API. This function is ran every minute. What I want to do is to catch ...
-1
votes
0answers
7 views

How to apply MultiTasking on the method for processing file and database

I've created a method which reads some specfic files from a path and have a foreach loop to get a particular info from the files and search that info in database then return the filename and modified ...
-1
votes
1answer
39 views

How to force an async function waits until another function finish? [duplicate]

This is my code: function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function user() { await mylibwrapper(async () => { await sleep(1110); // ...
0
votes
0answers
16 views

wait for a function without return value [duplicate]

someArray = [foo, bar, foobar]; someArray.forEach(async (record) => { //do something asynchronously }) how can I wait for the asynchronous function to finished?
0
votes
0answers
24 views

How to store user input as a variable in an async function in node.js

Basically I am looking for a substitute to var x = prompt("Question") inside of an asynchronous function specifically for node.js. Does such a thing exist? I have tried dependencies such as inquirer ...
-1
votes
1answer
49 views

run await functions one after one

There are a lot of samples on running Async/Await functions. But only with one await call. I don't find a right sample that I can run await functions one after one async function a() { ...
-1
votes
2answers
65 views

Bubble up Exception from Task.Run()

I have the code below and I am trying to bubble out the exception coming out from testFunction(). When i try to run the code there is no exception thrown. testFunction is a task which i want to call ...
0
votes
1answer
65 views

Limiting concurrent async tasks

I want to upload potentially large batches (possibly 100s) of files to FTP, using the SSH.NET library and the Renci.SshNet.Async extensions. I need to limit the number of concurrent uploads to five, ...
2
votes
1answer
26 views

An AsyncDuplicateLock that can be locked on all keys

I need a lock similar to the one from this answer from Stephen Cleary: http://resolved-error.com/a/31194647/4381408 However, I also need to be able to lock on all keys at the same time. I'm using ...
-1
votes
0answers
30 views

JavaScript wait until function call is finished before starting next one [duplicate]

I currently use an array of aEdits based on which I call the functions _updateStatus and _updatePlanning. The problem is that our system currently does not allow multiple calls to occur at the same ...
1
vote
1answer
26 views

How to async await with jQuery sortable receive and update?

I use sortable's receive to receive elements from a draggable list. When this happens, the element's data is sent to the server using an Ajax call and an entry is created in the database. Once done, ...
0
votes
0answers
24 views

socket.io control execution order with nested async and await

In my app, I have multiple users submitting data "at once" via a socket.event. Because I need to know if every user has submitted their data successfully, I try to indentify the first and last entry. ...
0
votes
1answer
25 views

Python async/await difference in execution time

I am timing two execution methods using async io CASE 1: async def test(): print(f"started at {time.strftime('%X')}") await asyncio.create_task(say_after(2, 'hello')) await asyncio....
-2
votes
1answer
42 views

Order of execution in promises in javascript

I have a sample program to understand how promises and async/ await works. But am a little bit confused about the execution order of promises. Can anybody explain how this works? CASE1 //Promise 1 ...
0
votes
0answers
14 views

cheerio .each async await doesn't actually wait [duplicate]

const rp = require( 'request-promise' ); const cheerio = require('cheerio'); async function scrapItem() { const item_url='some dummy url'; const html = await rp(item_url); const $ = ...
-1
votes
0answers
6 views

which one best for 'performance ,big-project & good looking & understanding code ' , callback or promise or async/await?

which one best for 'performance ,big-project & good looking & understanding code ' , callback or promise or async/await ?
3
votes
2answers
49 views

Converting promises to async/await - Javascript

I have a dataService function in React that does my API fetching. I tried converting to async/await block but seem to hit a roadblock. Using promises: const dataService = (url, options, dataToPost) =...
-1
votes
1answer
83 views

After Task.IsCompleted what is better: await or Result

I'm working in a simple timeout code for my http requests. I got this private async Task<HttpResponseMessage> ExecuteIOTask(Task<HttpResponseMessage> ioTask, int timeout) { ...
0
votes
1answer
40 views

nodejs reading value in google spreadsheet with await/async

I am using for-loop to iterate thru sheets in a google spreadsheet and access specific cell within each sheet. I have a google spreadsheet with five sheets Sheet1, Sheet2,.. , Sheet5. The value if the ...
2
votes
1answer
50 views

Task starting in UI context

I have this piece of code to run a "heavy" Task asynchronously (and potentially show a result on the UI). In my understanding, a new Task would always start in another context than the UI's. To test ...
-1
votes
2answers
56 views

How to make sure method called from taskList doesn't get executed simultaneously?

I have a method, that downloads a memoryStream from a cloudDrive and then passes this memoryStream to taskList which reads the file: public async Task CreateFiles(List<MyDataClass> list) {...
1
vote
2answers
70 views

Correctly implementing Tasks in a WPF application

I'm looking for some advice on getting to grips with Tasks in WPF and was wondering if anyone could have a look over my code and point out what I'm doing incorrectly? Basically the application takes ...
-1
votes
1answer
85 views

When using StreamWriter Async I get the error “The stream is currently in use by a previous operation on the stream”

I have a set of tasks that get strings that I am trying to coordinate into a stream. It all looks good, but in practice I am getting a The stream is currently in use by a previous operation on the ...
0
votes
1answer
57 views

LINQ LAMBDA Async Await Within Select

I have this code extract (incomplete - enough to demonstrate point): private async Task<IEnumerable<EntityViewModel>> GetOtherRoles(CallResult lpfProcess, IProductConfig productConfig,...
0
votes
1answer
36 views

Why all my requests are blocked until async/await method executed

I have an asp.net mvc async method waiting for 10 second. The problem is IIS Express (production IIS also) stops processing incoming requests until that async method finishes. I thought await keyword ...
1
vote
3answers
49 views

Using Async/Await on multiple settimeout

To understand async/await, I am trying to display a console message once settimeout runs and expires. How do I fix my code below? I have 5 settimeout function and each should display respective ...
0
votes
0answers
36 views

c# http request maximum concurrent connections are 40

I would like to create 1000 concurrent http client connections to different URLs. I have used async/await and waitall. below is my code static async Task<String> AsyncSend(String url) { ...
0
votes
1answer
23 views

List of synchronous dbcontext queries rewritten as async calls on separate contexts

This post is in the context of using Entity Framework version 6.2. Ok, so I have a rather slow endpoint that is essentially the following: public IHttpActionResult GetCounts() { int ...
2
votes
4answers
104 views

Marking a function as async but no await calls, any issues?

Are there any side effects to having a function that is marked as async, but it doesn't actually make any await calls? Eg: public interface IMyInterface { Task DoSomethingAsync(); } public class ...
-1
votes
0answers
17 views

Async/Await simple example in JavaScript [duplicate]

In this very simple code, I am trying to implement Async/Await so I can understand. I have read many tutorials but still failed to implement correctly. How to fix this code? Task: Send get request ...
0
votes
3answers
92 views

C# sync function to async

How I can change this function to async with Framework 4.6.1? The DGV has a lot of data and blocks the rest of the processes. DGV is updated every 30 seconds with timer. any other solution do not ...
1
vote
1answer
53 views

Do all functions in an `async/await` chain have to use the `async/await` keyword?

Do all functions in an async/await chain have to use the async/await keyword? async function one() { return await fetch(.....); } async function two() { return await one(); } async function ...
1
vote
1answer
21 views

Catching uncaught exception in async function (Javascript) [duplicate]

Currently I have code such as: window.onerror = function() { // Send some debug info about the defective error handling, // so that it may be fixed }; To handle otherwise uncaught exceptions....
0
votes
1answer
38 views

Node.Js API wait for dynamodb calls to finish to send to browser

I have a complex amount of code for dynamodb calls to the database. Basically I have several database calls to linked at the end of each other, and then on top of that I need to loop through multiple ...
0
votes
1answer
12 views

Passing an async callback

I am unsure of how to pass an inline async callback to a function. fraudListen = async () => { this.KYCinstance.events.ReportedFraud({fromBlock:0 }, (error, event) => { returnVar = ...
0
votes
1answer
43 views

Async/Await Axios returns promise and not data? [duplicate]

export const isLoginValid = async token => { try { let result = await axios.post(API_URL + "/verify", null, { headers: { Authorization: "Bearer " + token } }); return await ...
1
vote
4answers
173 views

Async method blocking on unawaited task

In my current project, I have a piece of code that, after simplifying it down to where I'm having issues, looks something like this: private async Task RunAsync(CancellationToken cancel) { bool ...
0
votes
1answer
17 views

AsyncInterceptor with Polly (AOP retry style)

For some part of my system I need to add retry logic for reading from the database. I have a number of repositories with async and sync read methods that I can't change. I found a simple solution - ...
2
votes
0answers
39 views

UWP SerialCommunication: await SerialDevice.FromIdAsync Does Not Return SerialDevice

Simple bit of code to return Port information: private async void GetPortNames() { string deviceSelector = SerialDevice.GetDeviceSelector(); DeviceInformationCollection deviceCollection = ...
1
vote
1answer
54 views

Redux shorthand `mapDispatchToProps` returns undefined for `async` actions / thunks

I have encountered what I think might be a bug but could be my understanding. Basically an import of an async action returns undefined inside a Redux container, but I know the import is fine (file ...
1
vote
0answers
39 views

What is meant by Context in Synchronization Context [duplicate]

One aspect of SynchronizationContext is that it provides a way to queue a unit of work to a context. Note that this unit of work is queued to a context rather than a specific thread. What exactly ...
3
votes
3answers
52 views

How do I structure tests for asynchronous functions?

I'm accustomed to writing Mocha tests using the standard NodeJs assert library like this: describe('Some module', () => { var result = someCall(); it('Should <something>', () => { ...
0
votes
0answers
42 views

Filter and remove reactive data. Vue.js

With local data all works fine, but when I getting my async data, it's starts behaving very strange — when I refresh the page it's showing the right data for a half a sec, but then changes to some ...

http://mssss.yulina-kosm.ru