Ejemplo n.º 1
0
        public void FireSimpleEvent()
        {
            using (WmiEventWatcher watcher = new WmiEventWatcher(1))
            {
                BaseWmiEvent myEvent = new TestEvent("Hello, World");
                System.Management.Instrumentation.Instrumentation.Fire(myEvent);

                watcher.WaitForEvents();
            }
        }
Ejemplo n.º 2
0
        public void Send100Events()
        {
            using (WmiEventWatcher watcher = new WmiEventWatcher(100))
            {
                for (int i = 0; i < 100; i++)
                {
                    BaseWmiEvent myEvent = new TestEvent("" + i);
                    System.Management.Instrumentation.Instrumentation.Fire(myEvent);
                }

                watcher.WaitForEvents();

                Assert.AreEqual(100, watcher.EventsReceived.Count);
                Assert.AreEqual("50", watcher.EventsReceived[50].Properties["Text"].Value);
            }
        }