On Wed, 22 Nov 2000, Stuart MacCallum wrote:

> Hi and thanks to all that reply in advance.
> 
> This should be an easy one to all those who are experienced in perl.
> 
> I have written a perl script that runs as a background process on the win32
> platform. Unfortunately it is hogging all of the CPU time and I am having
> problems trying to stop this.
> 
> I am using the win32 module in the following way to start the
> "eventhandle.pl" script, which runs constantly in the background.
> 
> Win32::Process::Create($val, 'D:\\perl\\bin\\perl.exe', "perl
> eventhandle.pl",
>                              1, "CREATE_SUSPENDED", ".");
> $val->SetPriorityClass(IDLE_PRIORITY_CLASS);   # I thought this would make
> sure the process only worked when the system was idle
> 
> $val->Resume;
> 
> The eventhandle.pl script continually checks the contents of  the file
> "flag.txt" to see if there is an event it has to complete, if so it does it,
> if not it rechecks the file again. I believe this loop is where the problem
> arises, does anybody know how I could free up the processor, or at least
> give me a hint or an online resource to turn to
>

Try using the "sleep" function after each check of the file. Even if
you just do a sleep(1) it should free up the processor for other stuff.
By cheking less frequently, say every 10 for 15 seconds I think that
you won't even notice that it is running. A more robbust solution would
be to have the OS notify you program when the event occurs rather than
have the program repeatly check. 

**** [EMAIL PROTECTED] <Carl Jolley>
**** All opinions are my own and not necessarily those of my employer ****

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to