How to dispose BackgroundWorkers the right way

Posted by radbyx on Stack Overflow See other posts from Stack Overflow or by radbyx
Published on 2010-05-31T22:36:47Z Indexed on 2010/05/31 22:43 UTC
Read the original article Hit count: 140

Filed under:
|
|

I've got a Windows Service that runs BackgroundWorker's, and I'm wondering if I'm doing the right thing when I stop my Windows Service.

Is it enough to:

  1. Let the BackgroundWorker1_DoWork method complete (I have a while loop in it now, doing some tasks)
  2. Set the variable that holds the reference to the BackgroundWorker, to null

Is there some kind of Dispose() method I need to call (In the same way the Timer class has Timer.Dispose();)?

© Stack Overflow or respective owner

Related posts about c#

Related posts about timer