How to implement a Stop/Cancel button?
问题 I have a method processData() that takes a large amount of data and does some work on it. There's a start button that initiates the processing. I need a cancel button that stops the processing wherever it's at. How can I implement something like that? The thing I don't get is how to make the cancel button usable once the processing has started since the rest of the UI is frozen when the function is running. 回答1: BackgroundWorker.CancelAsync Method is what you need. Here is a good example for