Click here to Skip to main content
16,021,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a background worker which i started on the click of a button with bw.RunWorkerAsync(). I have an infinite loop inside the backgroundworker. Now i want to cancel it at the click of another button. I tried bw.CancelAsync() but it did not work except if the bw finish working. But in my own case, the bw can never finish working because of the infinite loop inside it. So how do i "terminate" the bw even when it is busy?
I need to terminate it at the click of a button. I am using vb.net
pls help me!
Posted

In your DoWork method, do yuo check if the worker CancellationPending property is true? When that property is true, you should set the DoWorkEventArgs.Cancel to true and exit the method.
 
Share this answer
 
Thank you very much! It worked!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900