Skip to content

Commit 1e9c03f

Browse files
zhao-gangPolyMeilex
authored andcommitted
update async test
Now the async test can check API in multithreading.
1 parent ec72386 commit 1e9c03f

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

examples/async.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
fn main() {
22
// Spawn dialog on main thread
3-
let task = rfd::AsyncFileDialog::new().pick_file();
3+
let task1 = rfd::AsyncFileDialog::new().pick_file();
4+
let task2 = rfd::AsyncFileDialog::new().pick_file();
45

56
// Await somewhere else
67
execute(async {
7-
let file = task.await;
8+
let file = task1.await;
9+
10+
if let Some(file) = file {
11+
// If you are on native platform you can just get the path
12+
#[cfg(not(target_arch = "wasm32"))]
13+
println!("{:?}", file.path());
14+
15+
// If you care about wasm support you just read() the file
16+
file.read().await;
17+
}
18+
19+
let file = task2.await;
820

921
if let Some(file) = file {
1022
// If you are on native platform you can just get the path

0 commit comments

Comments
 (0)