HI I have created some dynamic wait methods.... but doesn't seem to work properly , any idea ?
// This one is related to mouse load
public static void WaitForMouseLoad(int maxLoopDuration)
{
string currentState = Mouse.Cursor.ToString();
System.DateTime start = System.DateTime.Now;
while ((currentState == "[Cursor: Default]" || currentState == "[Cursor: WaitCursor]") && System.DateTime.Now.Subtract(start).TotalMilliseconds < MAX_WAIT_TIME)
{
Thread.Sleep(500);
currentState = Mouse.Cursor.ToString();
}
if(System.DateTime.Now.Subtract(start).TotalMilliseconds > MAX_WAIT_TIME)
{
Ranorex.Report.Error("Application still reports busy state after exceeding the allotted time");
}
}
// this one is related to process being idle
public static void WaitForProcessIdle()
{
var perfCounter = new PerformanceCounter("Process", "% Processor Time", "Revit",true);
System.DateTime start = System.DateTime.Now;
perfCounter.NextValue();
float cpu = perfCounter.NextValue()/Environment.ProcessorCount;
Report.Info(cpu.ToString());
while (cpu > 0 && System.DateTime.Now.Subtract(start).TotalMilliseconds < MAX_WAIT_TIME)
{
Thread.Sleep(500);
cpu = perfCounter.NextValue()/Environment.ProcessorCount;
}
if(System.DateTime.Now.Subtract(start).TotalMilliseconds > MAX_WAIT_TIME)
{
Report.Failure("Application still reports busy state after exceeding the allotted time");
}
}
Any help on this would be great
Thanks,
Rajee
Dynamic wait
Re: Dynamic wait
Any thoughts on this please