The requirement is to run an automation to process PDF files in a directory every 5 minutes. When the time has elapsed, it should check whether the processing is completed. If it is not, it waits for another 5 minutes. I have used a boolean property to indicate whether the processing is completed.
You’ll need a WindowsForm to use the Timer. You can set the Opacity of the form to 0 and effectively make it invisible (especially if you hide it from the Task Bar). You want to make sure that the form is “Visible” (i.e. not minimized or hidden where you set Visible to False). With an Opacity of 0, it won’t actually have any pixels onscreen that you can see, but will still be technically Visible, allowing the Click event to fire. Here is an example where I set the timer to five seconds (much easier to test with). I wrapped the automation that does the work in a Try…Catch so that you can ensure it always allows the next interval to work regardless of the outcome of the prior interval. If the time fires while the prior run is still operating, it will simply get ignored and do nothing until the next interval.