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

Chapter 22. PSEventing: .NET Events in PowerShell

PowerShell gives you full control over all .NET objects—well, nearly full control. One often-missed feature is full support for consuming events. It is possible to subscribe to an event handler using PowerShell constructs; script blocks can be passed to .NET objects as delegates. The problem is that there are a lot of complexities involved in this process like thread synchronization and garbage collection—someone needs to manage object life spans so that events going across scripting boundaries do not find that their handler has been garbage collected. Additionally, we need some orchestration when it comes to raising events from multiple threads. PowerShell does not offer any intrinsic support ...

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