I haven’t used either in the scope of anvil, but I’m sure someone has discussed it on the forum.
I would look into Running Tasks in the Background, in this tutorial they set up a timer to communicate with background task. It shouldn’t hold up your UI either.