home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 21 / IOPROG_21.ISO / SOFT / OSLIB101.ZIP / SOURCE / AUTYIELD.C next >
Encoding:
C/C++ Source or Header  |  1998-04-14  |  2.1 KB  |  91 lines

  1. #include <extend.h>
  2.  
  3. #pragma optimize("lge", off)
  4.  
  5. // A (whisper it) static to hold the registration handle.
  6.  
  7. static USHORT uHandle = 0;
  8.  
  9. // Structure of a Clipper event.
  10.  
  11. typedef struct
  12. {
  13.     USHORT uUnknown;
  14.     USHORT uID;
  15. } EVENT;
  16.  
  17. // *** WARNING ***: Clipper internals, beware!!!!
  18.  
  19. USHORT _evRegReceiverFunc( void *, USHORT );
  20. void   _evDeregReceiver( USHORT );
  21.  
  22. // Prototype local functions.
  23.  
  24. void   _OL_AutoYieldToOS( EVENT * );
  25.  
  26. /*  $DOC$
  27.  *  $FUNCNAME$
  28.  *      OL_AutoYield()
  29.  *  $CATEGORY$
  30.  *      Functions
  31.  *  $ONELINER$
  32.  *      Automaticly return times slices back to the OS.
  33.  *  $SYNTAX$
  34.  *      OL_AutoYield( [<lOn>] ) --> lOld
  35.  *  $ARGUMENTS$
  36.  *      <lOn> is an optional logical variable that tells the function if
  37.  *      it should turn the yielding on or off. If not supplied the function
  38.  *      just returns the current setting.
  39.  *  $RETURNS$
  40.  *      The current/old setting.
  41.  *  $DESCRIPTION$
  42.  *      OL_AutoYield() can be used to yield time slices back to the
  43.  *      operating system in those situations where you don't have access
  44.  *      to or control over the code that is causing the slice hogging.
  45.  *      For example, if you were to use Clipper's "Menu To" command you
  46.  *      would not be able to make use of the OL_Yield() function so
  47.  *      turning on OL_AutoYield() will allow the yielding of times slices.
  48.  *  $EXAMPLES$
  49.  *      // Turn on auto yielding.
  50.  *
  51.  *      OL_AutoYield( TRUE )
  52.  *  $SEEALSO$
  53.  *      
  54.  *  $END$
  55.  */
  56.  
  57. CLIPPER OL_AutoYie()
  58. {
  59.     _retl( uHandle );
  60.     
  61.     if ( PCOUNT && ISLOG( 1 ) )
  62.     {
  63.         if ( _parl( 1 ) )
  64.         {
  65.             if ( uHandle )
  66.             {
  67.                 _evDeregReceiver( uHandle );
  68.             }
  69.             uHandle = _evRegReceiverFunc( _OL_AutoYieldToOS, 0x6001 );
  70.         }
  71.         else
  72.         {
  73.             _evDeregReceiver( uHandle );
  74.             uHandle = 0;
  75.         }
  76.     }
  77. }
  78.  
  79. // Hidden internal.
  80.  
  81. HIDE void _OL_AutoYieldToOS( EVENT *pEvent )
  82. {
  83.     if ( pEvent->uID == 0x5108 )
  84.     {
  85.         _asm {
  86.             Mov     AX,0x1680;
  87.             Int     0x2F;
  88.         }
  89.     }
  90. }
  91.