Reputation: 42440
So, this is roughly how my C# program looks
Main()
// call to method that reads XML file and loads it into a list of structure
// call to method that works on the structure, manpulates data etc.
// call to method that starts filewatching
Filwatching_method()
// if any change is detected, calls method OnChange
OnChange()
// Action on change
If OnChange
method is called i.e. a change has been detected, I want to repeat the entire process all over again. Should I call Main()
from OnChange
, or is there another way that is better?
Upvotes: 0
Views: 73
Reputation: 128317
Personally, this is what I think.
Main
from your OnChange
method, if that is in fact what you want to do (i.e., just run Main
again).Main
does not itself trigger OnChange
. This could be by either setting a flag or temporarily removing your Changed
handler and adding it back when you're done.Upvotes: 1
Reputation: 2340
Create one FileSystemWatcher object, which throws several events, you can handle every event differently.
Upvotes: 0
Reputation: 1038710
You may take a look at the FileSystemWatcher class which allows you to monitor and be notified of events happening on the file system like file being changed.
Upvotes: 2