Board index » cppbuilder » Where should i call my main loop?
Ramy
![]() CBuilder Developer |
Where should i call my main loop?2004-05-23 10:21:13 PM cppbuilder92 Hi all, In my application i'm having while loop that should run until the user press the 'Exit' key - void MainLoop( void ) { while ( !ExitFlag ) { Task1(); Task2(); Task2(); Application->ProcessMessages(); } } My problem is - where should i call this function?? i tried to call it from here __fastcall TForm1::TForm1( TComponent* Owner ) : TForm( Owner ) { MainLoop(); } and also i tried to call it from the 'FormCreate' event and from the first call to 'OnPaint' event, but in all this cases the form was not showed on the screen. What i did eventually was to start 100ms timer in the first call to the 'FormShow' event, in the timer event i set the timer OFF and i called to the 'MainLoop', it's working well but it's looks to me like a very Twisted way do that, becouse who ensures me that after the 100ms the form will finish it's creation? and if it finish it's creation (+ it's display) and it's taking it only 5ms to do that, then i just wasted 95ms at start... I want to call the 'MainLoop' function RIGHT AFTER the form has been created and shown, where should it be? Thanks Ramy |