AppServer jobs
StartJob(cName,cEnv,lWait,[parm1..parm25])Runs a routine in a separate thread with controlled return behavior.
Overview
StartJob receives a function, environment and lWait: true waits and returns the worker result; false returns NIL without confirming processing outcome. Up to 25 extra arguments are allowed; objects and code blocks reach the target as NIL. The proposed runnable example only multiplies a number and needs no tables. The consulted community pattern covers RpcSetEnv, semaphores and logging, but its illustrative credentials, writes and callbacks are not reproduced. (Sources: refs. 1–2.)
Syntax
StartJob(cName,cEnv,lWait,[parm1..parm25])Commented example
#Include "Protheus.ch"
User Function Ed499()
Local uResult
// Pure worker: no UI or table.
uResult := StartJob("U_Ed499W",GetEnvServer(),.T.,3)
ConOut(cValToChar(uResult))
Return Nil
User Function Ed499W(nValue)
Return nValue * 2With lWait true, the worker returns 6 for input 3. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Prepare company/branch when the worker needs data, release only its own environment and define concurrency, cancellation and idempotency.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.