How to do a desktop UDP communication in background?

I have a Xojo desktop app and want to start, with a button, an independent UDP communication in the background.

What is the best way to do/organize this?
Is a threat the right way?

Can I use UDP.write in a thead?

Any ideas or samples to get it running?

Many thanks, Bernd

A thread is the way to go, certainly. That way you don’t block the UI.

you may want to have nothing running, when nothing is to do.
So you react in events, e.g. process a package when DataAvailable handler is called.

And you may use a timer to do something regularly.

UDP already runs asych, ie., in the background.

So I will take a Thread for the UDP communication.
I was asking in this way because at my first try to use UDP.write in a threat was not running.
Thanks

But the UDP.DataAvailable doesn’t run in the thread. It always runs in the main UI thread. A thread seems superfluous. Unless you’re processing a large amount of data, then a thread might make sense. But I’ve not encountered a situation where I needed a thread.