` Printed Icetips Article

Icetips Article



Par2: Running a process in the background
2004-12-20 -- Lee White
 
What I've always done in cases where I want a background process to 
STAY in the background is to start it on its own thread when the app 
is loaded. I then put it to sleep and wake it up whenever it's needed 
by setting the TIMER on the hidden window.

--global equates--
EVENT:Sleep EQUATE(500h)
EVENT:Wake  EQUATE(501h)


MyProc PROCEDURE

Window Window...Timer(1)
  END

  CASE EVENT()
  OF EVENT:OpenWindow
    POST(EVENT:Sleep)
  OF EVENT:Sleep
    0{PROP:Timer} = 0
  OF EVENT:Wake
    < do any housekeeping here >
    0{PROP:TImer} = 1
  OF EVENT:Timer
    < do processing >
  ...
  END

When needed, simply POST(EVENT:Wake,,). This way the 
window is always open and doesn't grab focus from other windows in 
your app or other apps.



Printed November 21, 2024, 12:09 pm
This article has been viewed/printed 35226 times.