O'Reilly logo

Pro Windows PowerShell by Hristo Deshev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

22.2. Event-Handling Mechanics

An event in .NET is usually given a delegate, and the sender invokes that delegate when it raises the event. Many people are used to that paradigm and would probably expect that that would be the case with PSEventing. Maybe we can just pass a script block as an event handler—not so fast! PowerShell lacks good threading support for scripts, and firing an event from a foreign piece of code may be dangerous from a concurrency point of view.

That is why PSEventing takes a slightly different approach: it creates the abstraction of a global event queue. All access to the event queue will be synchronized to protect us from concurrency-related problems. The rules according to which the queue is filled are stored in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required