` Printed Icetips Article

Icetips Article



Par2: Closing all open windows
2000-05-31 -- Randy Goodhew
 
Here is a snippet of source code that allows you to
post an event to all threads without having the
overhead of creating a global queue and the code
needed to manage that queue.

! PostAll(),LONG  ! returns a count of all threads posted

PostAll      FUNCTION(LONG pEvent)
Save:Thread  LONG,AUTO       ! save the thread
J            LONG,AUTO       ! loop counter
Result       SHORT,AUTO      ! count of active threads
  CODE
  Result = 0                 ! blank the count
  Save:Thread = THREAD()     ! save current thread
  LOOP J = 64 TO 1 BY -1     ! loop through threads
    SETTARGET(,J)            ! attemp to set thread
    IF J = THREAD()          ! test if thread exists
      Result += 1            ! increment count
      IF NOT OMITTED(1)      ! count threads only, if event is omitted
        POST(pEvent,,J)      ! post event
      END !if
    END !if
  END !loop
  SETTARGET(,Save:Thread)    ! restore saved thread
  RETURN(Result)



Printed May 9, 2024, 7:41 pm
This article has been viewed/printed 35121 times.