Results 1 to 3 of 3

Thread: [RESOLVED] System.Management EventWatcher, best practices?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2013
    Posts
    985

    Resolved [RESOLVED] System.Management EventWatcher, best practices?

    Hi

    I'm playing around with this class a little and it seems that while waiting for an event to happen it well waits, freezing the thread until the event is fired.

    is this normal behaviour and if so lets say im monitoring the system, would i put these watchers into there own threads?

    or is this class not really meant for this?
    Yes!!!
    Working from home is so much better than working in an office...
    Nothing can beat the combined stress of getting your work done on time whilst
    1. one toddler keeps pressing your AVR's power button
    2. one baby keeps crying for milk
    3. one child keeps running in and out of the house screaming and shouting
    4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
    5. working at 1 O'clock in the morning because nobody is awake at that time
    6. being grossly underpaid for all your hard work


  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: System.Management EventWatcher, best practices?

    I've never actually used that class myself but, from a quick look at the documentation, it appears that you are probably calling the WaitForNextEvent method, which is synchronous and gets just the next event, when you should be calling the Start method, which gets all events up until you call Stop and returns them via the EventArrived event, which is presumably raised on a thread pool thread.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2013
    Posts
    985

    Re: System.Management EventWatcher, best practices?

    aahh , yes i was using waitfornextevent. i didnt try anything else yet
    thanks, ill have a look at those
    Yes!!!
    Working from home is so much better than working in an office...
    Nothing can beat the combined stress of getting your work done on time whilst
    1. one toddler keeps pressing your AVR's power button
    2. one baby keeps crying for milk
    3. one child keeps running in and out of the house screaming and shouting
    4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
    5. working at 1 O'clock in the morning because nobody is awake at that time
    6. being grossly underpaid for all your hard work


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width