async-await Questions
4
Solved
import asyncio
from sqlalchemy import Column
from sqlalchemy import DateTime
from sqlalchemy import ForeignKey
from sqlalchemy import func
from sqlalchemy import Integer
from sqlalchemy import Str...
Ascospore asked 25/11, 2021 at 1:35
2
Solved
I am practicing basic unit test cases with mocha and a bit confused HOW and WHEN to use done() handler.
How to use done() ?
Below is my sample code where I am not able to use done:
it('Testing in...
Brittenybrittingham asked 21/9, 2018 at 18:19
10
Solved
Given the following code:
var arr = [1,2,3,4,5];
var results: number[] = await arr.map(async (item): Promise<number> => {
await callAsynchronousOperation(item);
return item + 1;
});
...
Arboriculture asked 19/10, 2016 at 19:39
5
I have a function that streams data in batches via a callback.
Each batch will await the callback function before fetching another batch and the entire function returns a promise that resolves whe...
Guzzle asked 14/6, 2018 at 17:10
3
Solved
I have a dialog component, which executes two async functions on submit. My goal is to keep the dialog opened and show a loading state until both functions are finished. After it, I want to close t...
Pulcheria asked 11/3, 2021 at 13:42
3
Solved
I've been trying to get a conceptual understanding of why the following code doesn't catch the throw. If you remove the async keyword from the new Promise(async (resolve, ... part then it works fin...
Dispensable asked 29/3, 2017 at 3:18
3
Solved
Synchronous function call context
In JavaScript, it's easy to associate some context with a synchronous function call by using a stack in a global scope.
// Context management
let contextStack...
Leighleigha asked 12/2, 2023 at 14:56
4
Solved
I have a wrapper around Cache library and have the following method to retrieve the cached valued based on Key:
public async Task<T> GetAsync<T>(string key)
{
var serializedObject = a...
Eighteenth asked 10/7, 2018 at 22:39
3
Solved
I am building an app with Swift and SwiftUI. In MainViewModel I have a function who call Api for fetching JSON from url and deserialize it. this is made under async/await protocol.
the problem is t...
Coffman asked 4/11, 2022 at 14:9
15
Solved
I want to write an async method with an out parameter, like this:
public async void Method1()
{
int op;
int result = await GetDataTaskAsync(out op);
}
How do I do this in GetDataTaskAsync?
Slype asked 10/9, 2013 at 10:50
4
Solved
Explicitly use a Func<Task> for asynchronous lambda function when Action overload is available
Reading over this blog post on some of the gotchas of C#5's async/await. It mentions in Gotcha #4 something that is quite profound and that I hadn't thought of before.
Briefly, it covers the scena...
Kazantzakis asked 5/12, 2013 at 9:14
3
Solved
A quick google search will tell you to avoid using async void myMethod() methods when possible. And in many cases there are ways to make it possible. My question is basically an offshoot of this be...
Younker asked 15/5, 2020 at 20:12
6
Solved
I have an ObservableObject class and a SwiftUI view. When a button is tapped, I create a Task and call populate (an async function) from within it. I thought this would execute populate on a backgr...
Thapsus asked 12/4, 2022 at 4:38
1
I try to load a simple html in android webview. In the html file , it include a script like this, the method with "async".
<script >
async function test(){
alert("test");
}
test();
<...
Recapitulate asked 4/12, 2018 at 10:40
3
Solved
When implementing classes that have uses in both synchronous and asynchronous applications, I find myself maintaining virtually identical code for both use cases.
Just as an example, consider:
fr...
Pammy asked 14/3, 2019 at 0:4
3
Solved
Let me just post a simple example:
private void MyMethod()
{
Task task = MyAsyncMethod();
task.Wait();
}
private async Task MyAsyncMethod()
{
//Code before await
await MyOtherAsyncMethod...
Tollgate asked 23/10, 2013 at 13:37
5
Solved
I have an ASP.Net MVC 4 application that periodically calls an external API for information (resource). This resource has a rate limiter for the account (meaning other apps use the same pool and ma...
Gunsmith asked 6/2, 2014 at 6:30
7
Trying to understand what's going on with my GET request. I set this up on the backend using node.js. I first thought I was using the wrong .env, url, username, and password... but when I checked o...
Mv asked 6/3, 2020 at 4:7
10
Is there any scenario where writing method like this:
public async Task<SomeResult> DoSomethingAsync()
{
// Some synchronous code might or might not be here... //
return await DoAnotherThi...
Cuckoopint asked 30/9, 2013 at 15:30
4
Solved
I am using an external library that has async methods, but not CancellationToken overloads.
Now currently I am using an extension method from another StackOverflow question to add a CancellationTo...
Misbehavior asked 14/6, 2017 at 9:5
5
Solved
Below is a simplified version of where I am trying to set Thread.CurrentPrincipal within an async method to a custom UserPrincipal object but the custom object is getting lost after leaving the awa...
Tomasz asked 10/7, 2015 at 17:10
4
Solved
I have just started learning about MongoDB and I am trying to host my Node.js application locally via MongoDB Server 6.0 (without using Mongoose or Atlas).
I copied the async JavaScript code given ...
Kremlin asked 29/11, 2022 at 4:35
2
Solved
When does a Task actually start?
public void DoSomething() {
Task myTask = DoSomethingAsync();
Task.WaitAll(new[] { myTask }, 2000);
}
public async Task DoSomethingAsync() {
await SomethingEl...
Townsley asked 29/3, 2017 at 9:19
15
Solved
What'd be the most elegant way to call an async method from a getter or setter in C#?
Here's some pseudo-code to help explain myself.
async Task<IEnumerable> MyAsyncMethod()
{
return await D...
Bulldozer asked 6/7, 2011 at 20:6
2
Solved
Background:
I have a process using tokio::process to spawn child processes with handles in the tokio runtime.
It is also responsible for freeing the resources after killing a child and, according ...
Clevelandclevenger asked 5/4, 2020 at 11:29
© 2022 - 2024 — McMap. All rights reserved.