I am using Embarcadero C++ Builder (an engineer not programmer)
I find the Sleep function is only working for me in debug mode and not in release mode. I see references in StackOverFlow not to use Sleep, and rather to use TTimer.
I simply want my app to pause for a few seconds between drawing objects as per the Sleep(500); in the code below, so that I can see each object being drawn and can check they are correct, else it happens to fast to check.
DrawSelectedShape(k,Side,AddOrDeduct,Color); in the below code, is the process that needs pausing
for (int n=0; n<LiquidLoads->TankBasicData->NoLiquidTypes; ++n){
for (int m=0; m<LiquidLoads->TankBasicData->NumberOfTanks[n]; ++m)
{
for (int l=1; l<LongStrengths->TotalNumberOfParts+1; ++l)
{
if (LiquidLoads->TankHeaderArray[n][m]->GhsName == LongStrengths->PartHeader[l]->PartName)
{
for (int j=0; j<LongStrengths->PartHeader[l]->NoOfComponents; ++j)
{
int k = LongStrengths->PartData[l][j]->ShapeNumber;
int Side = LongStrengths->PartData[l][j]->Side;
float AddOrDeduct = LongStrengths->PartData[l][j]->Effectiveness;
AnsiString Color = LiquidLoads->TankBasicData->LiquidTypeColor[n];
DrawSelectedShape(k,Side,AddOrDeduct,Color);
Canvas->TextOut(1200, 300+(n*25),LiquidLoads->TankBasicData->LiquidType[n]);
Sleep(300);
}
break;
}
}
} }
The above code works perfectly in debug mode, but in release mode, it works fine through the first few shapes being drawn to canvas, then you get a spinning wheel mouse cursor for a while followed by a blank canvas.
So I am looking for an alternative to Sleep.
When using a TTimer (no experience) one would use the OnTimer event, and place code that runs repeatedly in the event with a delay related to the Timer1 Interval, which is not quite the same as just looking for a few seconds delay in the middle of a for-loop
This is how my rendering looks like:
Any advise, most appreciated.