Quote Originally Posted by jmcilhinney View Post
The simplest way to pause code is by calling Thread.Sleep. You don't want to do that on the UI thread though, because it will freeze the UI. The whole point of this class is to execute code on secondary threads though, so you can probably call Thread.Sleep with impunity in the DoWork event handler or any method called from it.
Currently What i have did is,

1. Declaring a shared boolean variable on Main Form. When pause is clicked, i change value there.
2. Adding a function to check if pause = true, if its true then starting a endless loop

like this.

While pause
end while

this is done in my worker class. so it doesnt hangs up UI. is this correct way?