Skip to content

How to handle long, blocking tasks in non blocking way? #3721

Answered by tronical
qarmin asked this question in Q&A
Discussion options

You must be logged in to vote

I think the most common approach right now is to take a Weak handle of your app, send it across through your thread(s) and when you're ready to make changes to the UI do it through a closure invoked in the event loop with the weak handle: https://slint.dev/releases/1.2.2/docs/rust/slint/struct.Weak#method.upgrade_in_event_loop

Another option would be to use an async runtime and an async enabled channel, where in a future you continuously read from the channel and you poll that future from the UI thread: https://slint.dev/releases/1.2.2/docs/rust/slint/fn.spawn_local (we don't have a good example of that yet)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by qarmin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants