Jump to content

DosTimerStop: Difference between revisions

From EDM2
No edit summary
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[image:legacy.png]]
This call stops a periodic interval timer started by [[DosTimerStart]], or an asynchronous timer started by [[DosTimerAsync]].
This function has been renamed to "[[OS2_API:CPI:DosStopTimer|DosStopTimer]]". [https://books.google.com.ec/books?id=u7WbsmbttwYC&pg=PT372&lpg=PT372&dq#v=onepage&q&f=false]
 
==Description==
This call stops a periodic interval timer started by DosTimerStart, or an asynchronous timer started by DosTimerAsync.  


==Syntax==
==Syntax==
<PRE>
  DosTimerStop (Handle)
  DosTimerStop


    (Handle)
</PRE>
==Parameters==
==Parameters==
; Handle (HTIMER) - input : Handle of the timer to be stopped.
;Handle (HTIMER) - input : Handle of the timer to be stopped.
 


==Return Code==
==Return Code==
rc (USHORT) - return
;rc (USHORT) - return:Return code descriptions are:
 
* 0 NO_ERROR
Return code descriptions are:
*326 ERROR_TS_HANDLE
 
* 0         NO_ERROR  
* 326       ERROR_TS_HANDLE  


==Remarks==
==Remarks==
DosTimerStop is used to stop an asynchronous one-shot timer started with DosTimerAsync or an asynchronous periodic interval timer started with DosTimerStart.
DosTimerStop is used to stop an asynchronous one-shot timer started with DosTimerAsync or an asynchronous periodic interval timer started with DosTimerStart.


No assumptions can be made about the state of the semaphore specified with DosTimerStart or DosTimerAsync. The application should put the semaphores into a known state.  
No assumptions can be made about the state of the semaphore specified with DosTimerStart or DosTimerAsync. The application should put the semaphores into a known state.


==Example Code==
==Bindings==
===C Binding===
===C===
<PRE>
<PRE>
#define INCL_DOSDATETIME
#define INCL_DOSDATETIME
Line 35: Line 24:
USHORT  rc = DosTimerStop(Handle);
USHORT  rc = DosTimerStop(Handle);


HTIMER           Handle;        /* Handle of the timer */
HTIMER Handle;        /* Handle of the timer */
USHORT  rc;            /* return code */
</PRE>


USHORT          rc;           /* return code */
===MASM===
<PRE>
EXTRN  DosTimerStop:FAR
INCL_DOSDATETIME    EQU 1
 
PUSH  WORD    Handle        ;Handle of the timer
CALL  DosTimerStop
 
Returns WORD
</PRE>
</PRE>
The following example sets an asynchronous one-shot timer for one second. It then sets an asynchronous recurring timer with a one-second interval, reporting each time an interval elapses. Finally, it stops the recurring timer.


==Example Code==
The following example sets an asynchronous one-shot timer for one second. It then sets an asynchronous recurring timer with a one-second interval, reporting each time an interval elapses. Finally, it stops the recurring timer.
<PRE>
<PRE>
#define INCL_DOSDATETIME
#define INCL_DOSDATETIME
Line 47: Line 47:
#include <os2.h>
#include <os2.h>


#define SEM_NAME       "\\SEM\\timer.sem"  /* Semaphore name */
#define SEM_NAME       "\\SEM\\timer.sem"  /* Semaphore name */
#define TIME_INTERVAL   1000L               /* Timer interval
#define TIME_INTERVAL 1000L /* Timer interval (in milliseconds) */
                                                  (in milliseconds) */


main()
main()
Line 73: Line 72:
   /* Report when timer expires (other work may be done here) */
   /* Report when timer expires (other work may be done here) */
   if(!DosSemWait(SemHandle,              /* Semaphore handle */
   if(!DosSemWait(SemHandle,              /* Semaphore handle */
                 SEM_INDEFINITE_WAIT))    /* Timeout period -
                 SEM_INDEFINITE_WAIT))    /* Timeout period - indefinite */
                                                    indefinite */
     printf("Time interval has elapsed.\n");
     printf("Time interval has elapsed.\n");


Line 86: Line 84:
   for(i=1; i<4; i++)
   for(i=1; i<4; i++)
     if(!DosSemSetWait(SemHandle,            /* Semaphore handle */
     if(!DosSemSetWait(SemHandle,            /* Semaphore handle */
                       SEM_INDEFINITE_WAIT))  /* Timeout period -
                       SEM_INDEFINITE_WAIT))  /* Timeout period - indefinite */
                                                      indefinite */
       printf("Recurring timer cleared semaphore %d times.\n", i);
       printf("Recurring timer cleared semaphore %d times.\n", i);
   if(!(rc=DosTimerStop(TimerHandle)))        /* Timer handle */
   if(!(rc=DosTimerStop(TimerHandle)))        /* Timer handle */
Line 94: Line 91:
</PRE>
</PRE>


 
[[Category:Dos16]]
===MASM Binding===
<PRE>
EXTRN  DosTimerStop:FAR
INCL_DOSDATETIME    EQU 1
 
PUSH  WORD    Handle        ;Handle of the timer
CALL  DosTimerStop
 
Returns WORD
</PRE>
==Related Functions==
*
 
 
[[Category:The OS/2 API Project]]

Latest revision as of 20:04, 2 December 2019

This call stops a periodic interval timer started by DosTimerStart, or an asynchronous timer started by DosTimerAsync.

Syntax

DosTimerStop (Handle)

Parameters

Handle (HTIMER) - input
Handle of the timer to be stopped.

Return Code

rc (USHORT) - return
Return code descriptions are:
  • 0 NO_ERROR
  • 326 ERROR_TS_HANDLE

Remarks

DosTimerStop is used to stop an asynchronous one-shot timer started with DosTimerAsync or an asynchronous periodic interval timer started with DosTimerStart.

No assumptions can be made about the state of the semaphore specified with DosTimerStart or DosTimerAsync. The application should put the semaphores into a known state.

Bindings

C

#define INCL_DOSDATETIME

USHORT  rc = DosTimerStop(Handle);

HTIMER  Handle;        /* Handle of the timer */
USHORT  rc;            /* return code */

MASM

EXTRN  DosTimerStop:FAR
INCL_DOSDATETIME    EQU 1

PUSH   WORD    Handle        ;Handle of the timer
CALL   DosTimerStop

Returns WORD

Example Code

The following example sets an asynchronous one-shot timer for one second. It then sets an asynchronous recurring timer with a one-second interval, reporting each time an interval elapses. Finally, it stops the recurring timer.

#define INCL_DOSDATETIME
#define INCL_DOSSEMAPHORES

#include <os2.h>

#define SEM_NAME       "\\SEM\\timer.sem"  /* Semaphore name */
#define TIME_INTERVAL  1000L  /* Timer interval (in milliseconds) */

main()
{
  HSEM      SemHandle;
  HTIMER    TimerHandle;
  USHORT    i;
  USHORT    rc;

  /* Create system semaphore to be used by timers */
  DosCreateSem(CSEM_PUBLIC,        /* Ownership - nonexclusive */
               &SemHandle,         /* Semaphore handle (returned) */
               SEM_NAME);          /* Semaphore name */

  /* Set the semaphore, then start a one-shot timer */
  if(!DosSemSet(SemHandle))        /* Semaphore handle */
    printf("Semaphore set.\n");
  if(!(rc=DosTimerAsync(TIME_INTERVAL,    /* Timer interval */
                        SemHandle,        /* Semaphore handle */
                        &TimerHandle)))   /* Timer handle (returned) */
    printf("One shot timer for %f seconds started.\n", TIME_INTERVAL/1000.0);

  /* Report when timer expires (other work may be done here) */
  if(!DosSemWait(SemHandle,               /* Semaphore handle */
                 SEM_INDEFINITE_WAIT))    /* Timeout period - indefinite */
    printf("Time interval has elapsed.\n");

  /* Start a recurring timer */
  if(!(rc=DosTimerStart(TIME_INTERVAL,    /* Timer interval */
                        SemHandle,        /* Semaphore handle */
                        &TimerHandle)))   /* Timer handle (returned) */
    printf("Recurring timer with %f second interval started.\n",
           TIME_INTERVAL/1000.0);
  /*  */
  for(i=1; i<4; i++)
    if(!DosSemSetWait(SemHandle,             /* Semaphore handle */
                      SEM_INDEFINITE_WAIT))  /* Timeout period - indefinite */
      printf("Recurring timer cleared semaphore %d times.\n", i);
  if(!(rc=DosTimerStop(TimerHandle)))        /* Timer handle */
    printf("Recurring timer has been stopped.\n");
}