This is related to a specific issue, but I think it is an "interesting" question for general use: In Windows (specifically 2k8 server, for me) you have a task that is triggered by an event (specifically, the UPS goes on battery because power failed) with a delay (the battery will last at least 15 minutes) and then perform some action (specifically, shutdown /s /t 60 /d U:6:12). But there is some other event (specifically, the UPS goes OFF battery because power has been restored) that should then block the first task from happening (specifically, don't shut down) IF it happens during the delay.
I started thinking about this because the software for managing server shutdown that came with my UPS is pure... oh, I'm supposed to be polite here aren't I? ... um... very very not good. So I was thinking about how to provide the standard shutdown before battery runs out functionality without it. Normally, the system would get a message from the UPS that the battery was about to run out, then shut down. This UPS does NOT send that message. It sends "I'm on Battery", "I'm on AC" and that. is. it. No message for "I'm about to die".
But I think that could be a useful trick for other situations as well. Anytime there is something that you want to do after something has been happening for a while without recovery. E.g. if you can't communicate with a remote PC for some period of time, send a message to the smart power strip to power cycle it... But not if the communication is restored. Or if you haven't been able to get data from one source for some period of time, switch to a backup data source... But not if the primary source starts responding.
Can it be done? I don't see a way...