Such operations should be done on a worker thread, so that you leave the GUI thread free. If the user presses the Abort button you signal the thread to stop (for instance with a boolean flag, but you...