asynchronous

universal windows, c#, await during app initialization

谁说我不能喝 提交于 2021-02-11 12:38:30
问题 I'm trying to port a simple app I had running on Windows Phone 8 to Universal Windows. I have a few files I need to load (locally) before constructing the main frame/page as those instruct how to create the page in the first place. There is a .XML and a few content files that are part of Assets. I used to do the initialization during the App.Application_Launching() which I guess now is replaced by App.OnLaunched(). The trouble is with the new asynchronous-only file IO I can't seem to find a

universal windows, c#, await during app initialization

≯℡__Kan透↙ 提交于 2021-02-11 12:38:17
问题 I'm trying to port a simple app I had running on Windows Phone 8 to Universal Windows. I have a few files I need to load (locally) before constructing the main frame/page as those instruct how to create the page in the first place. There is a .XML and a few content files that are part of Assets. I used to do the initialization during the App.Application_Launching() which I guess now is replaced by App.OnLaunched(). The trouble is with the new asynchronous-only file IO I can't seem to find a

Async List Comprehensions in Python

谁都会走 提交于 2021-02-11 12:31:46
问题 Is it possible to do a list comprehension in Python asynchronously? I am trying to make many calls to a web api, where the bulk of the wait time is waiting for data to come back, which I would like to do asynchronously. Then after the data is fetched, I want to return the data and store it in a variable. How would I go about doing this? Below is the non asynchronous code: api_data = [{data_name: get_data(data_name)} for data_name in data_name_list] Below is my attempted asynchronous solution:

How do nested Javascript returns “pass up” promises?

天大地大妈咪最大 提交于 2021-02-11 12:23:14
问题 This question has two parts, both relating to how Javascript promises are passed around functions using return statements. 1) I have simple Javascript function, which includes multiple return statements. The inner function returns a promise to an arrow function, the arrow function is also returned, like this: const returnMe(data){ return () => { return Promise.resolve(data); }; }; Could I write the following code? returnMe("Hello!").then((msg) => { console.log(msg) }); /// --> output "Hello!"

Why do you need to await AJAX calls in JS but not in C#?

徘徊边缘 提交于 2021-02-11 12:23:05
问题 In Javascript I am used to making API calls, using whatever library, using the await keyword. This effectively implements a promise and prevents the next line of code from executing until that line of code has completed. const response = await fetch("http://some-url.com/endpoint", { /* options */ }); const result = response.json(); This does not seem to be necessary in C#. I can make a thread-blocking call and it won't proceed to the next line without using await at all. var response =

Firing Recurring Tasks At The Same Time

怎甘沉沦 提交于 2021-02-11 11:58:53
问题 I am trying to get 2 tasks to fire at the same time at a specific point in time, then do it all over again. For example, below is a task that waits 1 minute and a second task that waits 5 minutes. The 1 minute task should fire 5 times in 5 minutes and the 5 minute task 1 time, the 1 minute task should fire 10 times in 10 minutes and the 5 minute task 2 times, on and on and on. However, I need the 1 minute task to fire at the same time as the 5 minute. I was able to do this with System.Timers

Async db calls using recursion

≯℡__Kan透↙ 提交于 2021-02-11 07:33:27
问题 I have a need to recursively descend a linked list database tree item 1-> item 2 -> item 3 -> item 4 -> item 5 -> item 6 -> item 7 -> item 8 my pseudo code is var getItems = function(itemid) { db.getitem(itemid, function(item) { item.items.forEach(function(subitem) { getItems(subitem.id) }) }) getItems(1) however, db.getItem is an asynchronous function I would like to return a JS object in the same structure as the diagram to the top-level caller what is the best way of achieving this ? I don

Performance implications of using Async Hooks

萝らか妹 提交于 2021-02-11 04:37:46
问题 I'm the author of a Node.js library and I want to use Async Hooks to improve DX. But I'm worried about performance. I've read stories saying that everything is fine, as well as stories where performance was a blocker. In theory, asynchronicity should only happen for IO operations and performance penality should be pretty much ~0. (As IO operations are several orders of magnitude more expensive than running JS code.) But, in practice, does running extra JS on each async call induces a non

Performance implications of using Async Hooks

◇◆丶佛笑我妖孽 提交于 2021-02-11 04:33:47
问题 I'm the author of a Node.js library and I want to use Async Hooks to improve DX. But I'm worried about performance. I've read stories saying that everything is fine, as well as stories where performance was a blocker. In theory, asynchronicity should only happen for IO operations and performance penality should be pretty much ~0. (As IO operations are several orders of magnitude more expensive than running JS code.) But, in practice, does running extra JS on each async call induces a non

Performance implications of using Async Hooks

一世执手 提交于 2021-02-11 04:33:11
问题 I'm the author of a Node.js library and I want to use Async Hooks to improve DX. But I'm worried about performance. I've read stories saying that everything is fine, as well as stories where performance was a blocker. In theory, asynchronicity should only happen for IO operations and performance penality should be pretty much ~0. (As IO operations are several orders of magnitude more expensive than running JS code.) But, in practice, does running extra JS on each async call induces a non