How to leave WPF Form open after running code on console window?

by Nov 26, 2016

I am trying to implement a WPF application but need to keep the form open after
showing results in the Powershell console. At present it closes each time.

$run.add_Click({
      $form.DialogResult = $true          #Triggers the ShowDialog() below.
})

if ($form.ShowDialog()) {
   Write-Host -ForegroundColor Cyan "Search starting …"
}