cFunNameName of the menu routine associated with the process.
AdvPL GuideFWGridProcess():New( cFunName, cTitle, cDescription, bProcess, [cPerg], [cGrid], [lSaveLog] )Builds a standard interface for configuring, monitoring and running AdvPL processes, including multi-threaded work distribution.
FWGridProcess organizes long-running routines into Information, SX1 Questions, Process Log and concurrency settings. A main code block controls the workflow, while an optional grid function lets CallExecute() distribute independent work units across configured threads.
FWGridProcess():New( cFunName, cTitle, cDescription, bProcess, [cPerg], [cGrid], [lSaveLog] )cFunNameName of the menu routine associated with the process.
cTitleTitle displayed in the interface.
cDescriptionDescription shown on the Information page.
bProcessMain processing block; it receives the cancellation flag by reference.
cPergSX1 question group used to build the parameter page.
cGridFunction called for each unit when grid processing is configured.
lSaveLogEnables persistence of SaveLog() messages in SXU.
New() returns the FWGridProcess instance. IsFinished() indicates whether execution completed; CallExecute() returns the control result for the submitted work unit.
#Include "TOTVS.ch"
User Function ExGridProcess()
Local oProcess
oProcess := FWGridProcess():New( ;
"MATA330", "Processing", ;
"Grid processing example", ;
{|lCancel| U_ExProcess(oProcess, @lCancel)}, ;
"MTA330", "U_ExUnit" ;
)
oProcess:SetMeters(2)
oProcess:SetThreadGrid(5)
oProcess:Activate()
ReturnThe standard interface opens with information and execution controls.
// MTA330 builds the Questions page.
oProcess := FWGridProcess():New( ;
"MATA330", cTitle, cDescription, bProcess, ;
"MTA330", "U_ExUnit" ;
)SX1 parameters are rendered with controls that match their data types.
User Function ExProcess(oProcess, lCancel)
Local nGroup
Local nItem
oProcess:SetMaxMeter(4, 1, "Groups")
For nGroup := 1 To 4
oProcess:SetMaxMeter(10, 2, "Items")
For nItem := 1 To 10
If !oProcess:CallExecute("Unit loaded", 1)
lCancel := .T.
EndIf
oProcess:SetIncMeter(2)
If lCancel
Exit
EndIf
Next nItem
If lCancel
Exit
EndIf
oProcess:SetIncMeter(1)
Next nGroup
ReturnEach meter follows one level of work and CallExecute() submits independent units to the grid function.
oProcess:SaveLog("Starting group " + cValToChar(nGroup))
ConOut(oProcess:GetLastLog())Messages can be viewed in the Process Log page and persisted in SXU when enabled.
© 2026 Usina.BR. Todos os direitos reservados. TOTVS, Protheus, Microsiga e seus respectivos logotipos são marcas de titularidade da TOTVS S.A. AdvPL é uma linguagem de programação desenvolvida pela TOTVS. O AdvPL Guia é um projeto independente, sem vínculo, representação, patrocínio ou afiliação com a TOTVS S.A., suas franquias ou representantes.