That is correct, it will hunt for it. I don't remember the exact order, but it does happen. But, that being said, if the second one worked, you now have a scoped thread that you can reference without hunting. It used to be the "variables" scope was used for all unscoped variables. Doesn't seem to be the case any more but I haven't really paid any attention to it until I saw this thread.
If creating a struct and naming the thread as a member of that stuct works, you should be good to go. I will warn though - make sure it also works on CF9 - I've had some things fail that were "scoped functions" on CF9 with insanely obscure errors (these worked with no problem in CF8). I won't go into detail here unless someone wants to know specifics, but make sure you test on 8 and 9. Allen ________________________________ From: ad...@acfug.org [mailto:ad...@acfug.org] On Behalf Of Mischa Uppelschoten Sent: Thursday, May 26, 2011 10:37 AM To: discussion@acfug.org Subject: RE: [ACFUG Discuss] CFThread name issue The first way of naming a thread fails, the second one works, but I was under the impression that unless a variable is *prefixed* with an "official" scope, like http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Variables_30.html it is considered unscoped and CF hunts for it when code refers to it? ________________________________ From: axunderw...@ups.com To: discussion@acfug.org Date: Thu, 26 May 2011 10:23:06 -0400 Subject: RE: [ACFUG Discuss] CFThread name issue Try one of these two...using the variables scope first <cfthread action="RUN" name="variables.thread1"> <cfset thread.myvar = rand()> </cfthread> <cfthread action="JOIN" name="variables.thread1"></cfthread> <cfdump var="#variables.thread1.myvar#"> or, try using a separate structure: <cfset myScope = StructNew() /> <cfthread action="RUN" name="myScope.thread1"> <cfset thread.myvar = rand()> </cfthread> <cfthread action="JOIN" name="myScope.thread1"></cfthread> <cfdump var="#myScope.thread1.myvar#"> ________________________________ From: ad...@acfug.org [mailto:ad...@acfug.org] On Behalf Of Mischa Uppelschoten Sent: Thursday, May 26, 2011 10:07 AM To: discussion@acfug.org Subject: RE: [ACFUG Discuss] CFThread name issue Thanks Steve, I understand what you're saying, but unless I missed something, my central question is not answered: how do I refer to a thread (from the spawning code) using a scoped variable? The code you refer to uses unscoped variables, which causes scope hunting. Mischa. ________________________________ Date: Thu, 26 May 2011 08:25:00 -0400 Subject: Re: [ACFUG Discuss] CFThread name issue From: nowhid...@gmail.com To: discussion@acfug.org A thread is a "forked" process... the whole point of running something in a thread is usually that you what to "fire and forget" Ie do some batch stuff then email the results. OR you want to fork to multiple threads and have them do the batch in multiple threads (possibly shortening your batch by the number of threads you spawn) If you want to find out how long that thread took to process it you can always cflog the results... the CF docs have an example of doing what you want: http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_t_04.html On Wed, May 25, 2011 at 5:51 PM, Mischa Uppelschoten <mup...@hotmail.com<mailto:mup...@hotmail.com>> wrote: I think this is more about naming the thread itself than passing values into it. Let's say I'm not interested in passing values in, or even the outcome of a thread, only how much time it took: <cfthread action="RUN" name="thread1"> <!--- long running action with no output here ---> </cfthread> <cfthread action="JOIN" name="thread1"></cfthread> <cfoutput>This took #thread1.ElapsedTime# ms.</cfoutput> How would I code the above and have CF *not* hunt for the scope that thread1 is defined in? ________________________________ From: t...@dynapp.com<mailto:t...@dynapp.com> To: discussion@acfug.org<mailto:discussion@acfug.org> Date: Wed, 25 May 2011 16:19:23 -0500 Subject: RE: [ACFUG Discuss] CFThread name issue I'm thinking that when you send something to thread, you have divorced it from the request scope entirely, hence, your inability to reference it as a request scope variable even with a syntactically correct var name. Based on what you're posting, I'd say scoping it into variables would solve the problem, yes? Or am I misunderstanding what you're saying completely? :) Troy Jones ___________________________________________________________________________________________ Troy Jones | Director of Technical Services | Dynapp Inc | 1-800-830-5192 ext. 603 | dynapp.com<http://www.dynapp.com/> | facebook.com/dynapp<http://www.facebook.com/dynapp> From: ad...@acfug.org<mailto:ad...@acfug.org> [mailto:ad...@acfug.org<mailto:ad...@acfug.org>] On Behalf Of Mischa Uppelschoten Sent: Wednesday, May 25, 2011 4:13 PM To: discussion@acfug.org<mailto:discussion@acfug.org> Subject: RE: [ACFUG Discuss] CFThread name issue That's another way of phrasing my question :-) Stuffing them into a struct works, so it's not some sort of issue w/ dot notation <cfthread action="RUN" name="MyStruct.thread1"> works. ________________________________ From: t...@dynapp.com<mailto:t...@dynapp.com> To: discussion@acfug.org<mailto:discussion@acfug.org> Date: Wed, 25 May 2011 15:00:08 -0500 Subject: RE: [ACFUG Discuss] CFThread name issue Can threads be referenced with the request scope? Troy Jones Error! Filename not specified. ___________________________________________________________________________________________ Troy Jones | Director of Technical Services | Dynapp Inc | 1-800-830-5192 ext. 603 | dynapp.com<http://www.dynapp.com/> | facebook.com/dynapp<http://www.facebook.com/dynapp> From: ad...@acfug.org<mailto:ad...@acfug.org> [mailto:ad...@acfug.org<mailto:ad...@acfug.org>] On Behalf Of Mischa Uppelschoten Sent: Wednesday, May 25, 2011 3:30 PM To: discussion@acfug.org<mailto:discussion@acfug.org> Subject: [ACFUG Discuss] CFThread name issue Running into a headscratcher with cfthread. CF 8 Ent, Win 2k3 This works: <cfthread action="RUN" name="thread1"> <cfset thread.myvar = rand()> </cfthread> <cfthread action="JOIN" name="thread1"></cfthread> <cfdump var="#thread1.myvar#"> this throws an error "Element THREAD1.MYVAR is undefined in REQUEST": <cfthread action="RUN" name="request.thread1"> <cfset thread.myvar = rand()> </cfthread> <cfthread action="JOIN" name="request.thread1"></cfthread> <cfdump var="#request.thread1.myvar#"> What gives? How do I prevent scope hunting when referencing the result of my threads? Thanks! Mischa. ________________________________ No virus found in this message. Checked by AVG - www.avg.com<http://www.avg.com/> Version: 10.0.1375 / Virus Database: 1509/3659 - Release Date: 05/25/11 ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform<http://www.acfug.org/?fa=login.edituserform> For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/<http://www.mail-archive.com/discussion@acfug.org/> List hosted by FusionLink<http://www.fusionlink.com/> ------------------------------------------------------------- ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform<http://www.acfug.org/?fa=login.edituserform> For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/<http://www.mail-archive.com/discussion@acfug.org/> List hosted by FusionLink<http://www.fusionlink.com/> ------------------------------------------------------------- ________________________________ No virus found in this message. Checked by AVG - www.avg.com<http://www.avg.com/> Version: 10.0.1375 / Virus Database: 1509/3659 - Release Date: 05/25/11 ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform<http://www.acfug.org/?fa=login.edituserform> For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/<http://www.mail-archive.com/discussion@acfug.org/> List hosted by FusionLink<http://www.fusionlink.com/> ------------------------------------------------------------- ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform<http://www.acfug.org/?fa=login.edituserform> For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/<http://www.mail-archive.com/discussion@acfug.org/> List hosted by FusionLink<http://www.fusionlink.com/> ------------------------------------------------------------- ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/<http://www.mail-archive.com/discussion@acfug.org/> List hosted by FusionLink<http://www.fusionlink.com> ------------------------------------------------------------- -- Steve Ross web application & interface developer http://blog.stevensross.com [mobile] (912) 344-8113 [ AIM / Yahoo! : zeriumsteven ] [googleTalk : nowhiding ] ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/<http://www.mail-archive.com/discussion@acfug.org/> List hosted by FusionLink<http://www.fusionlink.com> ------------------------------------------------------------- ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/<http://www.mail-archive.com/discussion@acfug.org/> List hosted by FusionLink<http://www.fusionlink.com> ------------------------------------------------------------- ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/ List hosted by FusionLink<http://www.fusionlink.com> ------------------------------------------------------------- ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/ List hosted by http://www.fusionlink.com -------------------------------------------------------------