public void Dispose()
protected virtual void Dispose(bool disposing)
if (processFileBackgroundWorker != null)
processFileBackgroundWorker = null;
If fxcop pounds its spoon on the tray and demands
IDisposable, and it's not an option to get rid of fxcop, I guess you're stuck paying your taxes.
It's a bit silly in this particular case, because
IDisposable is for disposing unmanaged resources when an object goes out of the scope of a
using block or a
catch, and viewmodels don't go out of scope in that way. So in normal viewmodel usage, nothing calls
But you do often discard them before program exit (at program exit, nobody cares if anything gets disposed -- it's all going straight in the dumpster). I would implement
IDisposable, make it correctly dispose of the
BackgroundWorker as you're doing, and if there is a point in your code where an instance of that viewmodel is discarded, I would explicitly call
Dispose() on it. You don't need
IDisposable for that, but it's harmless.