You are on the right track FileSystemWatcher implements the Component class, which requires you to dispose it after use. Since this is the case, the correct approach would be to have your FileProcessor class implement IDisposable as you suggested.
You are on the right track. FileSystemWatcher implements the Component class, which requires you to dispose it after use. Since this is the case, the correct approach would be to have your FileProcessor class implement IDisposable as you suggested.
Since you are going to have the FileProcessor object live for an extended period of time, you will not be able to use a using statement. This is because the object would attempt to get disposed before it was done with its work. This being the case, I would implement an event on the FileProcessor to notify the consumer when processing is complete.
When this is complete I would call the Dispose method on the FileProcessor object. The Dispose method should perform all cleanup required for that object - IE: timer, watcher, etc. For your reference, this is a good article which lays out some guidelines for when and how to use the IDisposable interface. Also, as a good practice, you will want to wrap the calls in the consumer in try/catch blocks - you need to ensure that no matter what happens, you attempt to free the resources.
Yes, good stuff - investigate also try/finally blocks. – Jeremy McGee Oct 12 at 14:29 How can I notify my main service class (class that called FileProcessor) that it has completed? – Jay Oct 12 at 14:42 Jay, if you need help with events, check out msdn.microsoft.Com/en-us/library/aa645739(v=vs.71).
Aspx – davids Oct 12 at 14:50 You can also run FxCop or depending on your version of Visual Studio, the Code Analysis tool. They both have rules to tell you which objects are not being disposed of properly. That way you can find all the objects and use the above techniques to clean up after them.
– Scott Wylie Oct 120 at 20:02.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.