BackgroundWorker vs background Thread
Posted
by freddy smith
on Stack Overflow
See other posts from Stack Overflow
or by freddy smith
Published on 2009-10-01T22:25:52Z
Indexed on
2010/03/27
17:33 UTC
Read the original article
Hit count: 366
I have a stylistic question about the choice of background thread implementation I should use on a windows form app. Currently I have a BackgroundWorker on a form that has an infinite (while(true)) loop. In this loop I use WaitHandle.WaitAny to keep the thread snoozing until something of interest happens. One of the event handles I wait on is a "stopthread" event so that I can break out of the loop. This event is signaled when from my overridden Form.Dispose().
I read somewhere that BackgroundWorker is really intended for operations that you dont want to tie up the UI with and have an finite end - like downloading a file, or processing a sequence of items. In this case the "end" is unknown and only when the window is closed. Therefore would it be more appropriate for me to use a background Thread instead of BackgroundWorker for this purpose?
© Stack Overflow or respective owner