Learning ColdFusion 8: CFThread Part IV - Cross-Page Thread References

<!--- Kill extra output. --->
<cfsilent>
 
	<!---
		We are going to build up the thread activity HTML.
		While I normally would return JSON data here, in
		order to keep the demo as simple as possible (and
		since AJAX is not the primary goal here), I am just
		going to render the innerHTML.
	--->
	<cfsavecontent variable="strThreadData">
	<cfoutput>
 
 
		<!--- Check to see if there are any threads. --->
		<cfif StructCount( APPLICATION.Threads )>
 
			<!--- Loop over the active threads. --->
			<cfloop
				item="strName"
				collection="#APPLICATION.Threads#">
 
				<!---
					Get a short hand reference to the thread.
					These threads are going to be removing
					themsleves from the application, so in
					order to minimize bad data references, get
					the thread reference.
 
					Once we have an independent reference to
					the thread, it won't matter if it has been
					removed from the APPLICATION scope.
				--->
				<cfset objThread = APPLICATION.Threads[ strName ] />
 
				<!--- Output the thread data. --->
				<strong>#objThread.Name#</strong><br />
 
				.....
 
				Start:
				#TimeFormat(
					objThread.StartTime,
					"h:mm TT"
					)#<br />
 
				.....
 
				Duration:
				#NumberFormat(
					((Now() - objThread.StartTime) * 86400),
					"0"
					)#
				seconds<br />
 
			</cfloop>
 
		<cfelse>
 
			<em>There are no active threads.</em>
 
		</cfif>
 
	</cfoutput>
	</cfsavecontent>
 
 
	<!--- Output the thread innerHTML. --->
	<cfcontent
		type="text/html"
		variable="#ToBinary( ToBase64( strThreadData ) )#"
		/>
 
</cfsilent>

For Cut-and-Paste