CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Posts
    9

    Sleep or SleepEx

    trying to get a dialog based app ( vc++5) to pause for a set ammount of time ( pause for 60 secs.. then do something..)
    and i use 'SleepEx(60000);' and get an error.I was told to use 'DWORD SleepEx(60000);' and no pause takes effect... any thing else I can use?


  2. #2
    Join Date
    Feb 2005
    Location
    MI
    Posts
    4

    Re: Sleep or SleepEx

    If you intend on using SleepEx, I would suggest setting the second argument of the SleepEx function (BOOL bAlertable) to FALSE to guarantee that the function willl not return until the time-out period has elapsed; however, I would imagine that the traditional Sleep function would work for most general purposes.

  3. #3
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Sleep or SleepEx

    Why do you want your user interface to pause for a minute ?

    As a guess you're using threads... and assuming that a thread will finish after
    a minute has gone by.

    Anyway, use Sleep instead of SleepEx. This'll have the desired effect.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  4. #4
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Sleep or SleepEx

    If you are using Sleep in a main thread, all window message processing including GUI update will be freeze.
    After trying to press button for couple of times while timeout is in effect, user may just call Task Manager and kill process thinking window hung.

    If you do it trying to synchronize threads, Sleep is not a good idea; use Event or Mutex or any thread synchronization method.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured