In many cases we have seen that processing times varies so it will wait for the processing to get idle and you can edit the max timeout in this , so this will help in cases of rendering and some process extensive work where we cant use any wait command or any other progress. I tried this most of the CAD Softwares like AutoCAD, SolidWorks, Navisworks, Revit, Aveva PDMS, Bentley Microstation, BricsCAD and it worked well.
//function is to Wait for CPU processing to get Idle and with a timeout time
function WaitForProcessing()
{
Log.Message("Memory Usage : " + Sys.Process("PROCESS").MemUsage);
var time1 = aqDateTime.Time();
while(Sys.Process("PROCESS").CPUUsage != 0)
{
Log.CheckPoint("While Loop : cpu usage " + Sys.Process("PROCESS").CPUUsage);
aqUtils.Delay(2000,"Wait for Processing"); //Waiting for 2 sec
//Timeout for max 10sec
var time2 = aqDateTime.Time();
var diff = time2 - time1;
if(diff >= 10000) ///Please edit the time accordingly
{
Log.CheckPoint("Max Timeout for While loop with time : " + diff);
break;
}
}
Log.Message("While Loop Completed with Cpu Usage : " + Sys.Process("PROCESS").CPUUsage);
}
Labels: