In case of BackgroundWorker, a cancel can be reported by the e.Cancel – property of the DoWork – event handler.
How can I achieve the same thing with a Thread object?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is a full example of one way of doing it.
In short; the thread checks a bool flag, and keeps runing as long as the flag is
true. I prefer this approach over callingThread.Abortbecuase it seems a bit nicer and cleaner.