example-projects icon indicating copy to clipboard operation
example-projects copied to clipboard

Use background threads

Open andrewdavidmackenzie opened this issue 2 years ago • 0 comments

this PR is more to request feedback on how it should be done, rather than think this is better than the original.

Things I saw:

  • main() was using tokio and a thread, where one of the two would do?
  • it was doing a background scan once a second, so the button wasn't very useful
  • I added a state Scanning, which changes the button text to show that (I would like to disable the button also)

But mainly, it looked to me like the scan coroutine just received the state from the receiver, and didn't do a scan, so scan.start() didn't actually do a new scan.

I couldn't get it working using co-routines, so did the thread thing in the button on_click(), but I would like to know how a background/async task like that should be triggered from a UI Button...

andrewdavidmackenzie avatar Apr 06 '22 17:04 andrewdavidmackenzie