User bio
404 bio not found
Member since Jan 27, 2016
Replies:

Hi Dmitrii,

Why not Sync from main()? 

Class User.DelayedTest Extends %RegisteredObject
{

ClassMethod Callback(interval As %String) As %Status
{
    Hang interval
    Write "Interval = ", interval, !
    Return $$$OK
}

Method RunWorkers(queue)
{
    #Dim queue as %SYSTEM.WorkMgr
    Set queue = ##class(%SYSTEM.WorkMgr).%New()
    For i = 1:1:5
    {
        Set status = queue.Queue("..Callback", $RANDOM(5) + 1) // Minimal delay is 1 second
        $$$ThrowOnError(status)
    }
}

ClassMethod Main()
{
    #Dim d = ##class(DelayedTest).%New()
    Do d.RunWorkers(.queue)
    Write "This should be printed first",!
    Set status = queue.Sync()
    $$$ThrowOnError(status)
    Write "Exiting...",!
}

}
Open Exchange applications:
Certifications & Credly badges:
Alexey has no Certifications & Credly badges yet.
Global Masters badges:
Followers:
Following:
Alexey has not followed anybody yet.