For some reason this feels sloppy as I'd rather cancel the event or something but perhaps this is the best I can do for this situation in terms of speed. Note: The code generally DOES work fine for most domains (not always). Ideas, etc? Thanks guys
private bool bIs_Domain_Whois_Available()
{
using (var whois = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "whois.exe",
Arguments = this.strDomain,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
})
{
whois.OutputDataReceived += new DataReceivedEventHandler(whois_OutputDataReceived);
whois.Start();
whois.BeginOutputReadLine();
whois.WaitForExit();
whois.OutputDataReceived -= new DataReceivedEventHandler(whois_OutputDataReceived);
}
return (this.bLastWhoisExists);
}
private void StopWhois()
{
Process[] p = Process.GetProcessesByName("whois.exe");
foreach (Process whois in p)
{ whois.Kill(); }
}
private void whois_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
string output = e.Data;
if (e.Data != null && e.Data != "")
{
if (output.Contains("No whois information found"))
{
this.bLastWhoisExists = false;
this.StopWhois();
return;
}
this.bLastWhoisExists = true;
}
}

New Topic/Question
Reply



MultiQuote





|