Home > front end >  Remove event handler in Powershell
Remove event handler in Powershell

Time:04-04

In Powershell, one may hook an event on a .NET object by calling add_EventName, like this:

$MyBlock = [System.EventHandler]{Write-Host Hello}
$MyObject.add_Completed($MyBlock)

How does one remove that event handler? Or reset the event to the state with no handlers?

CodePudding user response:

Like this:

$MyObject.remove_Completed($MyBlock)
  • Related