` Printed Icetips Article

Icetips Article



Par2: Background process
1999-07-27 -- Jim Gambon
 
>>I need an app to sit in the background, minimized or in the sys tray, which
>>watches for certain ASCII files to appear, then do something. I'll need to
>>watch for at least three different files, and run three different processes
>>depending on which file(s) appear.


>I have written exactly this app recently and here's some help to get you started:
>
>1) Standard Windows Template. The Window has a Timer on it of 100
>(once every second).
>
>2) Set up a QUEUE of filenames you want to wait for. You can load the
>QUEUE with data via the GETINI/PUTINI stuff from an INI file, or from
>a datafile that you have allowed the user to edit.
>
>3) The "countdown" to check for file existance can be done several
>ways depending on your need for exactness, but you might be able to
>just Increment a counter every EVENT:Timer event (once a second).
>
>4) On EVENT:Timer, If Countdown > = 60, then loop through the file
>list QUEUE. For every file in the QUEUE use the EXISTS() command to
>see if the file exists. (The tricky part is finding out if the file is
>still being written to.  I set up a DOS file and tried
>OPEN(thefile,18) to get exclusive access to it. If there was an error
>I skipped the file.)
>
>5) If the file exists, Using PowerRun from Berthume Software
>(http://members.aol.com/GBerthume/index.htm) run the process you need.
>
>6) Set the CountDown back to zero to wait some more.
>
>7) For the aesthetics I used Vince's Tray API stuff to put the program
>in the tray (can only work in 32-bits).
>
>The trick is to use Timer events so that the ACCEPT loop will YIELD to
>other processes.
>
>I hope this helps lead you to a solution. If your solution is to buy a
>working copy of the program please let me know .
>
>Jim
>
>
>



Printed November 23, 2024, 3:38 am
This article has been viewed/printed 35215 times.