Hi
in Thread I can use suspend/resume event. what the equivalent in backgroundworker component?
thanks
Printable View
Hi
in Thread I can use suspend/resume event. what the equivalent in backgroundworker component?
thanks
It is bad practice to arbitrarily suspend threads and Microsoft has deprecated the Suspend and Resume methods with the intention of removing them in future versions. That means that you should NOT be using them at all in any new code. if you want to suspend a thread then you should set a variable that indicates it is so. The thread being suspended can then test that variable at points at which it is safe to be suspended and then do so itself. A BackgroundWorker is just a friendly wrapper around a thread, so you can do the same thing. You simply set a variable that indicates that you want to pause the background operation and when it is safe to do so the methods called from the DoWork event handler can test that variable and pause the current thread if necessary.
Pausing and Resuming Threads
Hi. Thanks for reply.
What should I write in dowork to pause it? It is my first time use this component
Thanks