ColdFusion & Javascript: How to pause a web page process

Insert a Pause between processes

There have been times that I've needed to pause a step in my Coldfusion application. Maybe, I need to send out an email with an attachment. I've found that sometimes the process for building the attachment file did not complete, and the email was blank. Does seem odd, but it has happened.

You could have your application set off a schedule of the next processes with cfschedule, or just pause the application for a certain amount of time to give all the prior processes to complete.

Basically, I had an application writing several files to another server and an email was sent out with the same files as an attachment. For whatever reason, the email was going out blank. Ever since I placed the simple javascript pause in the code, the email has been working properly since.


basically, I would place the following snippet of code between the processes:

// copy file to another server for backup

<cffile action = "copy"
source = "D:\inetpub\domains\www\attachments\#trim(filename)#"
destination ="\\\sftp\test\#trim(filename)#">

// have the thread pause for 100 miliseconds for the copy to complete

thread = CreateObject("java", "java.lang.Thread");

// Send out email with attachment

<b>This is an automatic email.</b>
<cfmailparam file="D:\inetpub\domains\www\attachments\#trim(filename)#">


More by this Author

  • Tips For How to Stain Concrete Floors

    You don't always have to tile, carpet, or hardwood your floors. The new thing is to just stain the concrete that's already there. It's a lot of work, but if done properly, your home will look gorgeous. If you're...

  • How to Build Wooden Roof Trusses

    You may refer to a truss as the rafter, but it's basically the skeleton of the roof, carrying the weight of the frame and supporting the walls of the building. Trusses are very important to preventing the walls from...

  • How to Get Rid of Mice In and Around The House?

    Until this year, the only time that I've had mice or rats in the house were when my daughter had pet mice and rats, and one of those times we did have one loose in the house. (Science fair project got loose.) Anyway,...

Click to Rate This Article