Rolling Your Own CFPAUSE Tag

Somehow it came to my attention recently that BlueDragon supports a CFPAUSE tag. According to the documentation:

The CFPAUSE tag allows you to pause the execution of a page for a specified number of seconds. The interval attribute is required and must specify an integer value.

I’m not sure why you would want to do this (if your application is just too darn fast?), but if it appeals to you for some reason, and you’re using ColdFusion MX, here is my own CFPAUSE tag:

<cfparam name="attributes.interval" default="1"/><cfscript>thread = createObject("java", "java.lang.Thread");thread.sleep(javaCast("long", 1000*attributes.interval));</cfscript>

Here is the dynamic new CFPAUSE tag in action:

<cfimport taglib="/cf_tags" prefix="mm"/><html><cflog text="this"/><mm:pause interval="5"/><cflog text="is"/><mm:pause interval="5"/><cflog text="slow"/></html>

9 Responses to Rolling Your Own CFPAUSE Tag

  1. anonymous says:

    another way is to unix “sleep” command. and if you want it for windows too, then get unix tools from

  2. anonymous says:

    argh. not too nice to just cut out my cfexecute tag like that. plase add HTMLEditFormat() around user comments or something.

  3. You might want to use this tag to reduce load on the server, e.g. in my experience indexing PDF documents and the like with Verity seems to be quite demanding. This is particularly important in shared hosting environments, which is where I believe most CF apps reside.

  4. Sam says:

    Thanks for the code Christian. BlueDragon is a nice option but I think it’s horrible that they introduce new tags. At the very least they really should include them as custom tags, cf_pause, and not buillt in tags, cf_pause. Anyone working with bluedragon would probably be well advised not to use built in special tags directly but to wrap them in custom tags for easier migration.

  5. Christian Cantrell says:

    I agree that it would make more sense to treat new functionality as language extensions as opposed to native functionality. Wrapping new tags up in custom tags is a great idea, Sam.

  6. Todd says:

    I agree with Sam as well. I brought that up as a concern to Charlie A. of BlueDragon and said that I disagreed with them putting in new functionality (such as cfpause, plus.. I heard they made changes to the cfquery tag). I mentioned that this is going to seriously confuse users as to why this isn’t a general cfml tag and that they should just make it a bluedragon specific tag or offer it as a custom tag. It looks like bluedragon ignored my concerns.

  7. I put this UDF on a week or two ago. It’s in the queue right now… Sleep(500)

  8. Nathan, i’ve tried your sleep – udf, it works great.But, i need the script to give output to browser, pause in the middle of the cfm page and then continue. The sleep tag puts the whole page to sleep and than outputs the results.

  9. Why say’I’m not sure why you would want to do this (if your application is just too darn fast?)’.And then spend all this time working out how to do it in ColdFusion MX. Do I see the colour green! 🙂