I'm trying to put standard output from nmap into WPF window application (textbox exactly). I'm trying to use Dispatcher.Invoke but when nmap process starts everything just freezes. When I tried this in a console application (w/o Invoke), everything worked just fine, I think it's a problem with the Invoke method. Nmap itself is working, and finishing it work, but there is no response in my window.
Here's the code I'm using:
Process nmap = new Process();
nmap.StartInfo.FileName = Properties.Settings.Default.NmapResidentialPath;
nmap.StartInfo.Arguments = arguments.ToString();
nmap.StartInfo.UseShellExecute = false;
nmap.StartInfo.RedirectStandardOutput = true;
nmap.OutputDataReceived += new DataReceivedEventHandler(nmap_OutputDataReceived);
nmap.Start();
nmap.BeginOutputReadLine();
nmap.WaitForExit();
nmap.Close();
And the event handler method:
void nmap_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
if (!String.IsNullOrEmpty(e.Data))
{
this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => nmapOutput.Text += "\n" + e.Data));
}
}