Your question, your audience. Choose who sees your identity—and your question—with question security.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
if (conditionsMet()) return;
For a long running method that's processing a list or a collection etc then you put this inside your processing loop and you might want to use 'break' instead of 'return' to allow for finalisation processing outside the loop.
If you mean pause a method so it can pick up where it left off later then you could use a similar approach but you'll need to save the state and include logic that allows the method to pick up half way through. I guess you might pass the state in as an object that you can update. That way the calling code can take care of saving it away and making sure it passes the correct state back in.
If you want the user to have a cancel button then you're into more than one thread anyway, otherwise your UI is locked.
Hope this helps. Please post more details if you meed a more precise answer.