SetWaitableTimer confusions
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: SetWaitableTimer confusions

  1. #1
    George2 is offline Elite Member Power Poster
    Join Date
    Oct 2002
    Posts
    4,468

    SetWaitableTimer confusions

    Hello everyone,

    For SetWaitableTimer and CreateWaitableTimer, I have the confusions (even after Google, I can not find satisfied answers, seems the samples are very few and MSDN description is fuzzy).

    My questions are,

    1. For API SetWaitableTimer, what are the meaning and function of parameters pDueTime and lPeriod?

    http://msdn.microsoft.com/en-us/library/ms686289.aspx

    2. For API CreateWaitableTimer, what is the function and meaning of parameter bManualReset (what is the different between setting it to true and setting it to false)?

    http://msdn.microsoft.com/en-us/library/ms682492.aspx

    thanks in advance,
    George

  2. #2
    Join Date
    Jul 2002
    Posts
    2,511

    Re: SetWaitableTimer confusions

    pDueTime defines time when a timer ticks first time. lPeriod defines whether timer is periodic, and timer interval, after first timer tick. 0 - timer ticks only once. For example:

    LARGE_INTEGER liDueTime;
    liDueTime.QuadPart=-100000000;
    ...
    // Set a timer to wait for 10 seconds.
    SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0)

    bManualReset = FALSE.
    Such timer becomes unsignaled automatically when single thread Wait operator succeeds. This means, client which calls WiitForSignalObject for a timer, doesn't need to reset this timer after successful wait operation.

    bManualReset = TRUE.
    After wait operation timer should be reset. It is possible that more than one threads may successfully wait for the same timer.

  3. #3
    George2 is offline Elite Member Power Poster
    Join Date
    Oct 2002
    Posts
    4,468

    Re: SetWaitableTimer confusions

    Thanks Alex,

    Quote Originally Posted by Alex F View Post
    bManualReset = FALSE.
    Such timer becomes unsignaled automatically when single thread Wait operator succeeds. This means, client which calls WiitForSignalObject for a timer, doesn't need to reset this timer after successful wait operation.

    bManualReset = TRUE.
    After wait operation timer should be reset. It is possible that more than one threads may successfully wait for the same timer.
    One more question about bManualReset parameter. In my limited experience, when we synchronize operations between multiple threads, we wait on events. I do not know what do you mean wait on timer? Could you clarify or refer to some simple sampels please?

    regards,
    George

  4. #4
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,592

    Re: SetWaitableTimer confusions

    Hi!

    Just like you can wait on an event, you can also wait on a timer.

    Read the remarks in the WaitForSingleObject docs and you will understand.

    http://msdn.microsoft.com/en-us/libr...32(VS.85).aspx
    Nobody cares how it works as long as it works

  5. #5
    George2 is offline Elite Member Power Poster
    Join Date
    Oct 2002
    Posts
    4,468

    Re: SetWaitableTimer confusions

    Cool, zerver!

    Quote Originally Posted by zerver View Post
    Hi!

    Just like you can wait on an event, you can also wait on a timer.

    Read the remarks in the WaitForSingleObject docs and you will understand.

    http://msdn.microsoft.com/en-us/libr...32(VS.85).aspx
    regards,
    George

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center