To add Ben Doom's answer, I include sample code for the way this can be done. There are several approaches and ways of naming, organizing and calling the code below, but hopefully this is helpful.
At some point during the start of the request, save the process information in a common area and return the identifier to the client. Here is an example of the functions that can be used on a page or remote requests.
<cffunction name="createProcess" output="false"> <cfset var id = createUUID()> <cfset application.processInfo[id] = { progress = 0, kill = false }> <cfreturn id /> </cffunction>
The client can then check the progress of the request on the survey server or send a request to kill the process
<cffunction name="getProcessProgress" output="false"> <cfargument name="processID" required="true"> <cfreturn application.processInfo[arguments.processID].progress /> </cffunction> <cffunction name="killProcess" output="false"> <cfargument name="processID" required="true"> <cfset application.processInfo[arguments.processID].kill = true /> </cffunction>
The actual server process in question can then click on a function, for example, during a cycle, to check whether it should be interrupted and clear any work as necessary.
<cffunction name="shouldKillProcess" output="false"> <cfargument name="processID" required="true"> <cfreturn application.processInfo[arguments.processID].kill /> </cffunction>
source share