Can't delete the question so might as well answer it.
The problem only occurs if the timer reaches the Application.Exit()
line the first time it runs. (i.e. if the file is available already when the program is run). In this case Application.Exit()
is called before Application.Run()
where as if the timer doesn't reach the Application.Exit()
on its first run (i.e. file is not yet available) then Application.Run()
gets called and Application.Exit()
only gets called later.
So to solve this I just added a condition in the timers' tick methods to make sure they don't so anything on their first run.
I don't agree with restructuring the program as the way it stands I can run it through the task scheduler to download the files daily without a form and with the polling functionality and I can also run it through VS as a normal winforms app with buttons for testing, debugging and downloading files when something went wrong.