Stop heavy data processing with button

Hello.
I am developing an app for data processing. In this app I have implemented a callback that starts a heavy data processing step when a button is clicked but I would like to be able to stop this process by pressing another button for example. I con’t know how to stop the process in on callback.

Is there a straight forward way to do this?

Thank you in advance.