You need to get out of the "linear" progamming thought process

You need to allow the form to process events, and check the event queue while waiting for the countdown to expire. At the moment your function hijacks the processing, so nothing else can occur.

Probably the easiest way is to design a mechanism which allows you to register / deregister functions and call them in each loop of your main event processing code.

You then need to design your functions so that they check their state and exit asap rather than loop internally.

This means that you need to preserve state information between calls, probably by using global variables.

Unless KF has an alarm handler built-in?