asynchronous

How to run an asynchronous task from a non-main thread in Tokio?

随声附和 提交于 2021-01-22 03:56:24
问题 use std::thread; use tokio::task; // 0.3.4 #[tokio::main] async fn main() { thread::spawn(|| { task::spawn(async { println!("123"); }); }) .join(); } When compiling I get a warning: warning: unused `std::result::Result` that must be used --> src/main.rs:6:5 | 6 | / thread::spawn(|| { 7 | | task::spawn(async { 8 | | println!("123"); 9 | | }); 10 | | }) 11 | | .join(); | |____________^ | = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should

How to run an asynchronous task from a non-main thread in Tokio?

你。 提交于 2021-01-22 03:53:29
问题 use std::thread; use tokio::task; // 0.3.4 #[tokio::main] async fn main() { thread::spawn(|| { task::spawn(async { println!("123"); }); }) .join(); } When compiling I get a warning: warning: unused `std::result::Result` that must be used --> src/main.rs:6:5 | 6 | / thread::spawn(|| { 7 | | task::spawn(async { 8 | | println!("123"); 9 | | }); 10 | | }) 11 | | .join(); | |____________^ | = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should

How to run an asynchronous task from a non-main thread in Tokio?

我只是一个虾纸丫 提交于 2021-01-22 03:52:42
问题 use std::thread; use tokio::task; // 0.3.4 #[tokio::main] async fn main() { thread::spawn(|| { task::spawn(async { println!("123"); }); }) .join(); } When compiling I get a warning: warning: unused `std::result::Result` that must be used --> src/main.rs:6:5 | 6 | / thread::spawn(|| { 7 | | task::spawn(async { 8 | | println!("123"); 9 | | }); 10 | | }) 11 | | .join(); | |____________^ | = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should

How to await inside setInterval in JS?

风流意气都作罢 提交于 2021-01-21 03:55:25
问题 I have a code segment that looks like this: async function autoScroll(page, maxDate = null) { await page.evaluate(async () => { await new Promise(async (resolve, reject) => { try { const scrollHeight = document.body.scrollHeight; let lastScrollTop = 0; const interval = setInterval(async () => { window.scrollBy(0, scrollHeight); const scrollTop = document.documentElement.scrollTop; let lastDate = null; if (maxDate) { const html = new XMLSerializer().serializeToString(document.doctype) +

How to await inside setInterval in JS?

孤街醉人 提交于 2021-01-21 03:53:05
问题 I have a code segment that looks like this: async function autoScroll(page, maxDate = null) { await page.evaluate(async () => { await new Promise(async (resolve, reject) => { try { const scrollHeight = document.body.scrollHeight; let lastScrollTop = 0; const interval = setInterval(async () => { window.scrollBy(0, scrollHeight); const scrollTop = document.documentElement.scrollTop; let lastDate = null; if (maxDate) { const html = new XMLSerializer().serializeToString(document.doctype) +

Update the todo list without refreshing the page in express nodejs app

淺唱寂寞╮ 提交于 2021-01-20 18:45:51
问题 I am a newbee to the express nodejs applications. I want to make a todo list. This is how it looks so far. My question is when I add a todo, it takes some time to show the change since it reloads the page. How can I see the change in realtime without reloading the page. Thanks in advance. in tasks.jade h1= title .list .item.add-task div.action form(action='/tasks', method='post', id='12345') input(type='hidden', value='true', name='all_done') input(type='hidden', value=locals._csrf, name='

Update the todo list without refreshing the page in express nodejs app

纵饮孤独 提交于 2021-01-20 18:45:37
问题 I am a newbee to the express nodejs applications. I want to make a todo list. This is how it looks so far. My question is when I add a todo, it takes some time to show the change since it reloads the page. How can I see the change in realtime without reloading the page. Thanks in advance. in tasks.jade h1= title .list .item.add-task div.action form(action='/tasks', method='post', id='12345') input(type='hidden', value='true', name='all_done') input(type='hidden', value=locals._csrf, name='

How to add a callback function to an asynchronous job in powershell and get return data

送分小仙女□ 提交于 2021-01-19 08:24:51
问题 I've been searching around the internet and combining lots of different pieces of code, but I'm just not succeeding at creating a callback for my asynchronous job. The idea is that I want to run multiple jobs, and using the callback methods I will be able to parse the output from the different jobs to change certain states and output in the main script. Currently I have this, and although the event gets called, I'm unable to get the actual output. What am I missing here? $rsPool =

How to add a callback function to an asynchronous job in powershell and get return data

我与影子孤独终老i 提交于 2021-01-19 08:23:29
问题 I've been searching around the internet and combining lots of different pieces of code, but I'm just not succeeding at creating a callback for my asynchronous job. The idea is that I want to run multiple jobs, and using the callback methods I will be able to parse the output from the different jobs to change certain states and output in the main script. Currently I have this, and although the event gets called, I'm unable to get the actual output. What am I missing here? $rsPool =

Async Task Still Blocking UI Thread

社会主义新天地 提交于 2021-01-19 07:02:54
问题 I'm reallt trying to get my head around async/await and Tasks . I'm trying to get one method down so that I can use it throughout my program. Basically I have my own version of BusyIndicator that I want to display whilst work is being done. Here is a basic example; private async void OnPageLoad(object sender, RoutedEventArgs e) { var waitWindow = new PleaseWaitWindow(); waitWindow.Show(); await LoadCompanyContracts(); waitWindow.Close(); } private async Task LoadCompanyContracts() { await