<!--- MyThread.cfc --->
<cfcomponent extends="java.lang.Thread">
<cffunction name="run" access="public" returntype="any">
<!--- do stuff that you don't need to wait for here, like launching an .exe --->
</cffunction>
</cfcomponent>
<!--- .cfm page --->
<cfscript>
mt = createObject("Component", "MyThread");
mt.start(); // start is a method that would be inherited from Thread
</cfscript>
But alas, it's not that simple. CFC's can't inherit from java classes..
So... in this situation it might make sense to create a Java wrapper that extends thread, and lets us assign a function to run as the thread. Maybe something with a simple API like this..
<cffunction name="someFunction" ...>
<cfscript>
ThreadWrapper = createObject("Java", "ThreadWrapper");
ThreadWrapper.setMethodToRun(someFunction);
ThreadWrapper.start();
</cfscript>
But I'm not sure have Java/CF play together with function references since I've never tried passing one from CF to Java before. If I get a chance, I'll play around with this when I get home from work tonight.
-d
----- Original Message -----
From: Christian Cantrell
To: CF-Talk
Sent: Thursday, January 22, 2004 12:24 PM
Subject: Re: CF Start a process - don't wait for it to finish
On Wednesday, January 21, 2004, at 11:06 PM, Taco Fleur wrote:
> What's the best way to start/call a process in CF and not wait for it
> to
> finish?
I tried once to write a CFTHREAD tag (that spawned a new Java thread in
which some task would be performed), but it managed to eluded me.
Sounds like a good candidate for a future version of CF, unless someone
else has some ideas on how to do it.
Christian
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

