Note that there are some explanatory texts on larger screens.

plurals
  1. POIs event listener using CPU time
    text
    copied!<p>Maybe this is a dumb question, but do event listeners use CPU cycles like a timer, or are they inactive until the event is fired?</p> <p>Is it language specific, or do all languages handle this basically the same?</p> <p>I want to write a tiny service that only does anything when a network disconnect event is fired, and I don't want the service to use up resources just listening (other than memory of course).</p> <p>I plan to do something like this</p> <pre><code>using NetworkUtilities; ManagementEventWatcher networkAdapterArrivalWatcher = new ManagementEventWatcher("\\root\\wmi","SELECT * FROM MSNdis_NotifyAdapterArrival "); networkAdapterArrivalWatcher.Options.Timeout = new TimeSpan(0,0,5); ManagementEventWatcher networkAdapterRemovalWatcher = new ManagementEventWatcher("\\root\\wmi","SELECT * FROM MSNdis_NotifyAdapterRemoval " ); networkAdapterRemovalWatcher.Options.Timeout = new TimeSpan(0,0,5); ConnectionNotifierHandler handler = new ConnectionNotifierHandler(); networkAdapterArrivalWatcher.EventArrived += new EventArrivedEventHandler(handler.Arrived); networkAdapterRemovalWatcher.EventArrived += new EventArrivedEventHandler(handler.Removed); //Start watching for events networkAdapterArrivalWatcher.Start(); networkAdapterRemovalWatcher.Start(); public void Arrived(object sender, EventArrivedEventArgs e) { using (ManagementBaseObject ev = e.NewEvent) { //Log the event } } public void Removed(object sender, EventArrivedEventArgs e) { using (ManagementBaseObject ev = e.NewEvent) { //Log the event } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload