Ending @async task externally

Hello, does anyone know how to close an async task from within another thread? ive been trying to do it using methods like an endless loop with a bool array that is passed in externally but that doesnt seem to work.
Any ideas?

create a Channel, then in the body of your task (presumably, there’s a loop of some sorts), check that channel & abort the task if sees kill “instruction” (could just be a Bool) in the channel.

1 Like