- HubPages»
- Technology»
- Computers & Software»
- Computer Science & Programming
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.
CODE SAMPLE
basically, I would place the following snippet of code between the processes:
<script>
// copy file to another server for backup
</script>
<cffile action = "copy"
source = "D:\inetpub\domains\www\attachments\#trim(filename)#"
destination ="\\172.16.80.39\sftp\test\#trim(filename)#">
<cfscript>
// have the thread pause for 100 miliseconds for the copy to complete
</cfscript>
<cfscript>
thread = CreateObject("java", "java.lang.Thread");
thread.sleep(100);
</cfscript>
<cfscript>
// Send out email with attachment
</cfscript>
<CFMAIL
FROM="email"
TO="email"
SUBJECT="FILES ATTACHED"
TYPE="HTML">
<b>This is an automatic email.</b>
<br>
FILES ATTACHED
<br>
<cfoutput>
<cfmailparam file="D:\inetpub\domains\www\attachments\#trim(filename)#">
</cfoutput>
</CFMAIL>
Some other Coldfusion Articles
- Adobe Coldfusion Tip For Finding Duplicate Records In SQL Database
- Coldfusion: allowing max file size when uploading
- ColdFusion: Monitor Hard Drive Space And Email Alert
- Coldfusion SQL Tips: Creating Tables, Backup, Fields
- Coldfusion Programming: Accessing a shared network drive
- Coldfusion: Encrypting and Decrypting Data
- Adobe Coldfusion Help: Query To Spreadsheet
- ColdFusion: Upload a pipe delimited file and insert into SQL table
- Coldfusion programming: How to submit muliple records at the same time that have the same field name
- How To Upload Multiple Files With ColdFusion
- ColdFusion & Javascript: How to pause a web page process