How do I suppress my event-handling function from emitting unwanted text?
Clash Royale CLAN TAG #URR8PPP How do I suppress my event-handling function from emitting unwanted text? I have a PowerShell script that composes a WinForms UI. Here are the pertinent bits: cls [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") Function FormClosed() { $global:Canceled = $true } $global:MainForm = New-Object 'System.Windows.Forms.Form' $global:MainForm.add_FormClosed({FormClosed}) $global:MainForm.ShowDialog() When I run the program, I get a PowerShell console window and the UI (as expected). When I click the main form control box "X", the function FormClosed is invoked (as expected). However, the text Cancel unexpectedly appears in the console window. FormClosed Cancel I put a breakpoint on $global:Canceled = $true in the function FormClosed . At this breakpoint, I step and then I see the execution pointer is on the } i...