Apache::ASP Powered by ModPerl & Apache Powered by Apache::ASP
Demo ASP: register_cleanup.asp 2024-10-10

We are about to sleep for 3 seconds. Before that, this script registers a routine to be executed after this script finishes, which will increment a count. This count displayed after these 3 seconds if you do nothing.

Try this. Hit reload, then your browser STOP button quickly. Do this repeatedly. Then let the script execute normally. You will see the registered code executed appropriately.

Up through Apache version 1.3.4, this method is important, because mod_perl halts script execution immediately when the user hits a STOP button, so doing $Server->RegisterCleanup is the only way to consistently execute code that you have to for that script.

sleeping for 3 seconds...

sleeping 1 second...
sleeping 1 second...
sleeping 1 second...

Count incremented in $Server->RegisterCleanup 0

view this file's source