I\'ve got a class named BackgroundWorker
that has a thread constantly running. To turn this thread off, an instance variable named stop
to needs to
Out of interest, any reason this couldn't use the regular BackgroundWorker, which has full support for cancellation?
Re the lock - a volatile bool field might be less troublesome.
However, in this case your finalizer isn't doing anything interesting, especially given the "if(disposing)" - i.e. it only runs the interesting code during Dispose(). Personally I'd be tempted to stick with just IDisposable, and not provide a finalizer: you should be cleaning it up with Dispose().