• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Cfthread question

Advisor ,
Jun 12, 2013 Jun 12, 2013

Copy link to clipboard

Copied

Hi All,

My first try using cfthread. I want two calculations to run at the same time:

<cffunction name="getData" output="false" access="remote">

<cfargument name="req_id" type="numeric" required="yes" />

<cfset var returnArray = ArrayNew(1)>

<cfthread name="processQuery" action="run">

     <cfset myObj = CreateObject("component", "myComponent") />

     <cfset returnArray [1] = myObj.getCalculationA(arguments.my_id) />

     <cfset returnArray [2] = myObj.getCalculationB(arguments.my_id) />

</cfthread>

<cfthread name="processQuery" action="join" />

<cfreturn returnArray />

</cffunction>

It is not returning anything. What am i missing?

Thanks in advance.

Views

486

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Jun 12, 2013 Jun 12, 2013

Couple issues with variables scope, but the time of the function still the same.

Do i need to setup something in the cf administrator?

I am using cf 9 enterprise.

Here is my new code:

<cffunction name="getData" output="false" access="remote">

<cfargument name="my_id" type="numeric" required="yes" />

<cfset variables.my_id = arguments.my_id />

<cfset variables.returnArray = ArrayNew(1) />

<cfset variables.myObj = CreateObject("component", "myComponent") />

<cfthread name="processA" action="run">

     <cfse

...

Votes

Translate

Translate
Advisor ,
Jun 12, 2013 Jun 12, 2013

Copy link to clipboard

Copied

Couple issues with variables scope, but the time of the function still the same.

Do i need to setup something in the cf administrator?

I am using cf 9 enterprise.

Here is my new code:

<cffunction name="getData" output="false" access="remote">

<cfargument name="my_id" type="numeric" required="yes" />

<cfset variables.my_id = arguments.my_id />

<cfset variables.returnArray = ArrayNew(1) />

<cfset variables.myObj = CreateObject("component", "myComponent") />

<cfthread name="processA" action="run">

     <cfset variables.returnArray [1] = variables.myObj.getCalculationA(variables.my_id) />

</cfthread>

<cfthread name="processB" action="run">

         <cfset variables.returnArray [2] = variables.myObj.getCalculationB(variables.my_id) />

</cfthread>

<cfthread name="processA, processB" action="join" />

<cfreturn variables.returnArray />

</cffunction>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 12, 2013 Jun 12, 2013

Copy link to clipboard

Copied

LATEST

I included other threads and i see the difference on the time.

Nice feature of CF !!!

Best,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation