wwDotNetBridge::RunThread

Allows firing off a PRG file on a new thread. Compiles and executes this PRG and can fire events to an loEvents object passed in as a parameter. You can implement callback functionality on the loEvents object.

The loEvents object must inherit from ThreadRunnerEvents which provides basic events for OnStarted,OnCompleted,OnCancelled,OnError

Note:
Requires ThreadRun.dll which contains ThreadRun.ThreadRunner COM object. This FoxPro COM object must be registered on the machine.

o.RunThread(lcPrgFilename,loEvents)

Parameters

lcPrgFilename
The path to the PRG file to run. FullPath() is applied to this file.

loEvents
Object that inherits from ThreadRunnerEvents. Object can implement properties and methods that can be called from the PRG file that executes.

The PRG file receives this event object as a single parameter.

Example

*** Load ThreadRunnerEvents base object
Do ThreadRunnerEvents

*** Event object must persist so make it public
*** or attach to an application level object as a property
public poEvent

*** Create an event object instance
poEvent = CREATEOBJECT("MyEventHandler")

*** Create wwDotNetBridge instance
loBridge = CREATEOBJECT("wwDotNetBridge")

*** Fire off the thread. Returns immediately - thread runs in background
loBridge.RunThread("ThreadRun.prg",poEvent)

RETURN


DEFINE CLASS MyEventHandler as ThreadRunnerEvents

FUNCTION Notify
LPARAMETER lcMessage
wait window nowait lcMessage
ENDFUNC

ENDDEFINE

The PRG can then run a long running task.

*** ThreadRun.prg
LPARAMETER loEvents

DO wwhttp

loEvents.Notify("Processing Started.")

loHttp = CREATEOBJECT("wwhttp")
lcHtml = loHttp.HttpGet("http://www.west-wind.com/somelongrunning.htm")
Sleep(2000)

loEvents.Notify("Processing Complete")

See also:

Class wwDotNetBridge

© West Wind Technologies, 1996-2019 • Updated: 06/07/17
Comment or report problem with topic