As yet another followup to my blog entry on CFTHREAD, a user asked about how to present a 'Please stand by' type message while the threads were running. This is fairly trivial with JavaScript and CFFLUSH:
<cfset threadlist = "">
<cfloop index="x" from="1" to="5">
<cfset name = "find more cowbell #x#">
<cfset threadlist = listAppend(threadlist, name)>
<cfthread name="#name#">
<cfset sleep(3000)>
<cflog file="tdemo" text="All done with #thread.name#, baby.">
</cfthread>
</cfloop>
<cfoutput>
<span id="loader">
#repeatString(" ",250)#
Please stand by...
</span>
</cfoutput>
<cfflush>
<cfthread action="join" name="#threadlist#" />
<script>
document.getElementById('loader').innerHTML = ''
</script>
<cfdump var="#cfthread#">
This is a slightly modified version of my previous code entry. Notice that I've added a span called loader with a bit of HTML. (The white space in front is to ensure IE renders the text.) After the cfthread/join action, I then use a bit more JavaScript to get rid of the loader. That's it. I'd normally use jQuery and some fancy loading graphic (like a unicorn, a magical unicorn), but hopefully you get the idea.