Click here to Skip to main content
15,921,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have program that have start and stop
start button that is run instead loop:
-first loop change proxy then open browser .
-second loop open urls in chrome browser that opened in first iteration.

stop button:

I want it stop loop and reset .

I can't press in stop button while start button is running.

What I have tried:

I tried background

1-
http://stackoverflow.com/questions/3065700/how-to-start-and-stop-a-continuously-running-background-worker-using-a-button

I can press stop but i can't see chrome browser

2-

http://stackoverflow.com/questions/27580241/breaking-from-a-loop-with-button-click-c-sharp

I but my code instead of
Console.WriteLine("Hello, world");
when i debug code i see it does't run code in
_worker.DoWork += new DoWorkEventHandler((state, args) =>
{ });
and select it with yellow color.
Posted
Updated 29-Jul-16 8:41am

1 solution

Sounds like you could use some info on Asynchronous operations with thread safe cancellations.

Take a look here [Thread Safe Operations]

Need to allow the cancelling of your other process by checking the cancelled flag.

OR: if you really want to use the background worker, you can have the button set a flag and during the event to report progress from the background worker check the flag and then safe cancel within that call.
 
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