Languages

Menu
Sites
Language
sleep() misbehaves with MessageBox

Hi,

Created a Ui app with a Button. On Click of the button with in OnActionPerformed() of MainForm, created and launched a MessageBox with a 3 seconds delay. Soon after that i kept sleep for about 10 seconds. MessageBox disappears only after 13 seconds i.e., 3 + 10 (MessageBox wait seconds + Sleep seconds)

Code snippet:

{
    MessageBox messageBox;
    messageBox.Construct(L"MessageBox Title", L"MessageBox Sample Code.", MSGBOX_STYLE_OK, 10000);
    
    int modalResult = 0;
    
    messageBox.ShowAndWait(modalResult);

    sleep(30);
}

Please clarify.

Thanks

Anil

Responses

1 Replies
Pushpa G

AFAIK,

First you are constructing messageBox with 10sec as timeout, so once it is created, in between it sleeps for 30sec(here as per your code). So after 30sec, once it awakes, it completed the remaining timeout of messagebox from the point where it left (on execution of sleep). So it diappears between 30 to 40sec(30+10)

Thanks,