I have a tool running, and is invoked through a BAT file in Command Prompt. In the tool, the Quartz scheduler periodically invokes a method, which performs the logic.
As per current implementation, all this is done through a single thread, thus even if the CTRL+C is performed on the BAT file, the tool is not shutdown until the process completes.
But, after looking at the process, we came up with the idea of performing part of the process in a separate thread. Here, the main thread would create a new thread, which would go on to perform some time consuming operations, while the parent thread dies. And another flow might be started by the Quartz even before the child thread has ended.
Thus, at a time, there can be only one parent thread, which the Quartz creates, but there can be any number of child threads operating.
In the above scenario, if CTRL+C is performed, then the Quartz scheduler only waits for the parent thread to complete before shutting down, and all other threads are left incomplete.
I would really appreciate it if someone can tell me how can keep the tool running until all threads have completed.
Thanks in advance.
PS: I have tried attaching the newly created child threads as shutdown hooks, but it doesn't seem to solve my problem. Maybe I am doing it wrong, but it hasn't helped me as of yet.