Wherever I see examples of using the BackgroundWorker in .NET I see people adding Thread.Sleep(int). Maybe I am missing something, but what's its benefit if you don't want to wait? Wherever I use BackgroundWorker I am performing lengthy operations which I want them to be completed as soon as possible.
If you don't want to wait, there isn't one. People may be using this to share time between other threads as @the_lotus commented.
Also, since you mentioned seeing this in examples, you have probably witnessed someone deciding to type one, easy to comprehend line in their tutorial rather than generating enough code that it actually takes long enough to run to demonstrate the background worker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With