As soon as the service SchedSvc starts, it scans the the registry for tasks in the location HKLM/Software/OGroeger/SchedSvc. For each task that is correctly parsed, it creates a new thread. Depending on the value of the registry value IntervalInMs it creates a PeriodicThread (IntervalInMs > 0) or a PhoenixThread (IntervalInMs = 0).
The thread function of a PeriodicThread performs the following:
- Create a WaitableTimer with the given Interval length.
- Starts this WaitableTimer.
- Waits for the timer and an event signaling that the service shall stop.
- If the timer gives a signal, the thread creates a new process with the given executable name and saves the new process handle.
- If the stop event occured the thread will kill the timer and close each process handle of all started but not terminated processes.
- Terminate itself.
The thread function of a PhoenixThread performs the following:
- Creates a process with the given executable name
- Waits for the process termination and an event signaling that the service shall stop.
- If the process terminated, the thread creates a new process with the given executable name.
- If the stop event occured the thread will kill the timer and close the process handle.
- Terminate itself.