House of Fusion
Home of the ColdFusion Community

Search cf-talk

December 02, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31       

Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Can I Use This CFScript Like This?

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Rick,
Weidler, Wilfred C.
08/29/08 01:01 P
Well... my attempt didn't work.
Rick Faircloth
08/29/08 03:48 P
Rick,
Weidler, Wilfred C.
08/29/08 03:54 P
Thanks, Chuck! I'll give that a go.
Rick Faircloth
08/29/08 04:03 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
08/29/2008 12:14 PM

I'm trying to set up a way to check the status of threads and implement a sleep function that loops and delays a following thread's initialization until the status of the first thread is "Completed". I found an example in the CF8 docs using a sleep timer this is placed just inside the opening <cfthread...> tag of the cfthread that needs to wait.     <cfscript>         thread.sleepTimes=0;         thread.initialized=false;         while ((2_hmls_offices.Status != "COMPLETED") && (2_hmls_offices.Status                 != "TERMINATED")) {             sleep(2000);             thread.sleeptimes++;         }         // Only do the post-initilization code if 2_hmls_offices is complete.         If (threadA.Status == "COMPLETED") {             thread.initialized=true;             // Post-initialization code would go here.         }     </cfscript> I understand what's happening inside the cfscript, but I'd like to continue the processing *outside* the cfscript tag and use regular CFML, not cfscript for the thread. This example states, in the last line "//Post-initialization code would go here". Can I just use the cfscript as is and follow the cfscript block with my cfqueries, etc., or would all my thread processing have to occur within the cfscript block?  Is there a way to break out of the cfscript block once the status of the first thread, "2_hmls_offices", is "Completed" and go on to process regular CFML code? Thanks, Rick

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Weidler, Wilfred C.
08/29/2008 01:01 PM

Rick, I have not tried it the way you have described, but I do use the Java sleep like so:   go_to = createObject("java", "java.lang.Thread");   go_to.sleep(5000); //sleep time in milliseconds Chuck I'm trying to set up a way to check the status of threads and implement a sleep function that loops and delays a following thread's initialization until the status of the first thread is "Completed". I found an example in the CF8 docs using a sleep timer this is placed just inside the opening <cfthread...> tag of the cfthread that needs to wait.     <cfscript>         thread.sleepTimes=0;         thread.initialized=false;         while ((2_hmls_offices.Status != "COMPLETED") && (2_hmls_offices.Status                 != "TERMINATED")) {             sleep(2000);             thread.sleeptimes++;         }         // Only do the post-initilization code if 2_hmls_offices is complete.         If (threadA.Status == "COMPLETED") {             thread.initialized=true;             // Post-initialization code would go here.         }     </cfscript> I understand what's happening inside the cfscript, but I'd like to continue the processing *outside* the cfscript tag and use regular CFML, not cfscript for the thread. This example states, in the last line "//Post-initialization code would go here". Can I just use the cfscript as is and follow the cfscript block with my cfqueries, etc., or would all my thread processing have to occur within the cfscript block?  Is there a way to break out of the cfscript block once the status of the first thread, "2_hmls_offices", is "Completed" and go on to process regular CFML code? Thanks, Rick

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
08/29/2008 03:48 PM

Well... my attempt didn't work. After emptying the database tables that are filled with data upon running the .cfm file with the threads, all the tables were filled but the one with the cfscript in it. Chuck, I guess that I would use your java sleep code like so? <cfloop from="1" to="1000"> <cfif cfthread.2_hmls_offices.status is not "completed">     go_to = createObject("java", "java.lang.Thread");     go_to.sleep(5000); //sleep time in milliseconds <cfelse> Run queries, etc... </cfif> Is your good just like it is or does it need script tags around it? Such as: <script type="text/javascript">     go_to = createObject("java", "java.lang.Thread");     go_to.sleep(5000); //sleep time in milliseconds </script> Thanks, Rick ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Weidler, Wilfred C.
08/29/2008 03:54 PM

Rick, That code is ran in a <cfscript> block. You only have to create the object one.  So the code would look something like this. <cfscript>   go_to = createObject("java", "java.lang.Thread"); </cfscript> Or if you prefer tags.... <cfset go_to = createObject("java", "java.lang.Thread")> <cfloop from="1" to="1000"> <cfif cfthread.2_hmls_offices.status is not "completed">   <cfscript>     go_to.sleep(5000); //sleep time in milliseconds   </cfscript>   Or if you prefer tags....   <cfset go_to.sleep(5000)> <cfelse> Run queries, etc... </cfif> Chuck Well... my attempt didn't work. After emptying the database tables that are filled with data upon running the .cfm file with the threads, all the tables were filled but the one with the cfscript in it. Chuck, I guess that I would use your java sleep code like so? <cfloop from="1" to="1000"> <cfif cfthread.2_hmls_offices.status is not "completed">     go_to = createObject("java", "java.lang.Thread");     go_to.sleep(5000); //sleep time in milliseconds <cfelse> Run queries, etc... </cfif> Is your good just like it is or does it need script tags around it? Such as: <script type="text/javascript">     go_to = createObject("java", "java.lang.Thread");     go_to.sleep(5000); //sleep time in milliseconds </script> Thanks, Rick ----- Excess quoted text cut - see Original Post for more ----- is "Completed" ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
08/29/2008 04:03 PM

Thanks, Chuck!  I'll give that a go. Rick ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists