05-28-2011 03:38 PM
Hi,
I need some help here. I am running a system based on the Duration;
I am starting by getting the test_duration first and I am using a for loop to stop the system based on the test duration specified.
But the for loop is freezing the panel. I cannot do any thing on the panel (like resetting.... no other button works) until the for loop completes.
could someone help me here. I don't want the for loop to freeze the panel.
Thank you.
void runTest (int h1, int s1, int p1)
{
double startTime, endTime;
int i;
int duration;
int x = 2;
GetCtrlVal (panelHandle, PANEL_TEST_DURATION , &test_duration);
startTime = Timer();
startSystem(); //start the system
SetCtrlVal (panelHandle, PANEL_LED_TR, 1);
for (i=0; i<test_duration; i++)
{
Delay (2);
endTime = Timer();
duration = endTime - startTime;
if (duration == x)
{
displayMessages ();
x+=2;
}
}
stopSystem();
SetCtrlVal (panelHandle, PANEL_LED_TR, 0);
}
05-28-2011 05:23 PM
Hi agyna, this is the behaviour you can expect! The fact is that your loop is not processing user interface events, so you are not able to manipulate the UIR and have events fired. You should put a ProcessSystemEvents inside the loop in order to have events processed. Moreover, the main time in your loop is spent into Delay () functon, so you should rewrite the code replacing that instruction with a small loop that processes events.
Take a look at this discussion that examines a situation very similar to yours and make also a search in the forum for ProcessSystemEvents: you will find a lot of useul threads that discuss similar situations and give alternative solutions to them.
05-28-2011 05:58 PM
Thanks Roberto for the suggestions.