TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: jan danielsson
from: Jonathan de Boyne Pollard
date: 1995-12-27 22:46:04
subject: semaphores & timers

jd>
  > .. WndProc(HWND hWnd, ......)
  > {
  >    switch(msg)
  >    {
  >       case WM_TIMER:
  >          rc = DosPostEventSem(hevDoIt);
  >          break;
  >    }
  > }
jd>

  You could also use DosStartTimer if you want an event semaphore to be
  posted on a regular basis.

jd>
  >    _but_.. should i add another 'infinitive-wait' semaphore
  > before the DosPostEventSem, which makes sure that no
  > 'dubble' postings are done?.. (to make a more even 'flow').
jd>

  If you are worried about lost events, then use the `pulPostCnt'
  parameter to DosResetEventSem.

  Also, rather than incrementing a counter and only performing any
  action every 100 events (which requires the thread to iterate over the
  loop code unnecessarily 99 times), why not simply multiply the timer
  delay interval by 100 ?

  On the other hand, why are you using a timer to trigger an event
  semaphore that kicks a thread into life in the first place.  Why not
  just put a DosSleep() call into the loop in your thread ?  Then you
  won't need either the timer or the semaphore.

  > JdeBP <
___
 X MegaMail 2.10 #0:
--- Maximus/2 3.00
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 808 809 934 955 712/407 515
SEEN-BY: 712/517 628 713/888 800/1 7877/2809
@PATH: 440/4 141/209 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.