Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: multiple infinitive loops

by ozkaa (Acolyte)
on Oct 06, 2004 at 16:34 UTC ( #397068=note: print w/replies, xml ) Need Help??


in reply to Re: multiple infinitive loops
in thread multiple infinitive loops

Thanks for all the replies :)

Im on windoze and using the
Win32::OLE("WbemScripting.SWbemLocator");

There is an event handler on it ExecNotificationQuery()->NextEvent();

Which is locking everything up.

I tried using a async threads but it still locks on the event.

I will look at the WaitForMultipleEvents

Many Thanks,
Oscar

Replies are listed 'Best First'.
Re^3: multiple infinitive loops
by ikegami (Pope) on Oct 06, 2004 at 17:03 UTC

    I don't know anything about these scripting/locator things, but a quick look at the MSDN Library shows that NextEvent accepts a timeout. Therefore, a simple solution is:

    use constants TIMEOUT => 50; use constants wbemErrTimedOut => 0x80043001; while (1) { $o1 = $h1->NextEvent(TIMEOUT); ProcessEvent1($h1, $o1) if ($o1 != wbemErrTimedOut); $o2 = $h2->NextEvent(TIMEOUT); ProcessEvent2($h2, $o2) if ($o2 != wbemErrTimedOut); }
      yes, but I don't want it to timeout because its a critical thing to keep on monitoring the processes

      Oscar
        It depends on how NextEvent works. If it just gets something from a queue (likely), you won't lose anything. It'll just get the event the next pass through the loop.
Re^3: multiple infinite loops
by melora (Scribe) on Oct 06, 2004 at 16:52 UTC
    I was working on a perl script under windows recently and found that it blocked (wouldn't even time out) while attempting to connect to a network socket (This wasn't a problem on other platforms.). I ended up forking a child process to attempt the connection, and having the parent kill it if it went too long. From what you've shown so far, I would suggest trying to fork a child process for each of those event-handling tasks. That would allow both event handlers to be available and avoid blocking everything when one process blocks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://397068]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2021-11-27 03:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?