I am working with a console application that scans multiple image directories and re-sizes then saves images if they exceed a certain size. Once a directory is finished processing a log is then pushed to a web-service page.
This utility program will be run at night for a given number of hours but must be shut down before normal office hours the following day, regardless of if it finished processing the current folder.
I am aware of 3 options to shut the program down:
DateTime
and if after certain time close itTimer
, set tick to a few hours, once tick handler is called then set a bool flag to false. After processing each image check the bool flag to see if it is time to shut the program down.Does the timer option have a performance advantage over comparing DateTime?
Is there perhaps an even better way? Maybe I am missing something?
Checking the DateTime
between processing seems like the best approach here.
Even if you use a Timer
, you'll likely still want to check the current time when the timer event fires to make sure that it's time to exit. Just checking the time against a cutoff time seems like the simplest option all around.