Hi,
You can try to do two things:
1. Set a boolean global variable and, between a call and the other of your function, if that variable equals to true, stop the execution. The button will make that variable equal to true.
public bool ShouldStop = false;
public void MyFunction(){
if (!ShouldStop)
else
return;
}
2. As proposed by Salman622 in the comments, use a BackgroundWorker or a new thread for that function and call Abort when the button is clicked.
Hope it helps.
LG