Closed valadaptive closed 2 months ago
In fact, even AsyncFileDialog
is block, .await
means the task will blocked until it complete
to solve it, I think you should spawn another task to call AsyncFileDialog
, and let your main loop check whether it is completed.
In fact, even
AsyncFileDialog
is block,.await
means the task will blocked until it complete
That's not how Future
s work in Rust. When you await
a future, it doesn't block the thread; it causes the task to "yield" (within whatever executor you're using, it'll move on to the next task to be executed, and probably won't poll that future again until the task is awoken).
@valadaptive I mean, the thread won't be blocked, but the task will be blocked, even it's async
Yes, but in the current code, the thread that the executor is running on is blocked, because the future blocks when polled. This means that no other futures can be executed while the file dialog is open, and if the executor is running on the main thread, the application itself will freeze. That's what I'm fixing.
Resolved by #191
AsyncFileDialog should allow the application to continue running while the file dialog is open, but on Windows, it causes it to freeze and eventually cause a "not responding" popup. This seems to be due to mutex shenanigans where
ThreadFuture
locks the mutex immediately in the thread that it spawns, then blocks on it when youpoll
it.