How to create delay or pooling mechanism to fetching items from Queue?


Hi RPA experts,

I have questions regarding using Delay activity in UiPath with running 30 + robots on one server.

While I am using Delay Activity with 00:00:02 seconds with multiple robots on same server, it utilizing the CPU usage to 99%.

I am building process to pull the requests from queue and process the queue item once is done. When there is nothing in queue robot is going in infinite loop until next item is available. To make sure the SQL server is not bombarded with multiple request I am using delay and that causing high CPU usage.

Is there a better way to wait? I have tried custom activity with timer and Invoke code activity using following logic, it result in same.

Dim keepChecking As Boolean = True
Dim interval As Int32
interval = 5000
Dim startTime As DateTime = DateTime.Now
While (keepChecking)
If (DateTime.Now > startTime.AddMilliseconds(interval))
keepChecking = False
End if
End While

I am running out of options, any help is appreciated.