How can I have a WinForms program do some specific thing whenever a certain time-based condition is met?
I was thinking I could do something with two threads, where one thread runs the normal program, and the other thread merely loops through checking if the time-based condition is true yet or not, and when the condition is true it signals an event.
However I am unsure of the best way to do it. Where in the program would I call the two threads? Maybe I am thinking about it all wrong?
How would you do this?
MORE INFO: What it has to do is check the data.dat file and see when the last time it was updated was. If it was a month or more then do the specific thing. Could this still be done with a Timer?
NOTE: I think it might be useful to note the difference between the System.Timers and the System.Windows.Forms.Timer…
I think you should use a Timer set to an inteligent interval to check if your time-based condition is met.
It depends what your time-based condition is. Is it a special time or an interval after which you want to do something special? If it’s the second, you can just use the Timer and do what you have to do when the Timer.Elapsed event is fired.
Edit after your edit: If you want an event to be fired every time the file changes, use a FileSystemWatcher
Edit2: Here’s the difference between System.Windows.Forms.Timer and System.Timers: