Charles, Scot,
Perhaps Scot can step through his code and tell us if the delay is coming
when he steps into the GetHostByName method, or when he steps into the
Catch. Personally, I haven't noticed any delays in .NET code when an
exception is being thrown for the first time. Maybe thats because I'm not
looking for it
Raymond Lewallen
"Charles Law" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Raymond
>
> I have no doubt that you are correct, however, I had assumed that Scot was
> referring to the time it takes to catch and throw an exception.
>
> I have noticed that the first time an exception is thrown and caught, a
..NET
> application can take a significant time (several seconds) before returning
> control to the catch block.
>
> Unfortunately for Scot, I don't know why this should be, so I am watching
> this thread with interest in case there is anything I can do about it as
> well. It does not seem to matter whether the exception is thrown manually
> either; the first time always takes several seconds.
>
> Charles
>
>
> "Raymond Lewallen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Scot,
> >
> > This is mostly likely due to the time it is taking for your DNS server
to
> > attempt to resolve the DNS name to an IP address. It is not uncommon
for
> > 3-6 seconds to pass while DNS attempts to resolve an entry that does not
> > exist. There is no way around the time it takes for a DNS server to
> exhaust
> > its resources in an attempt to resolve hostnames to ip addresses.
> >
> > HTH,
> >
> > Raymond Lewallen
> >
> > "Scot" <(E-Mail Removed)> wrote in message
> > news:c5184s$(E-Mail Removed)...
> > > I have the following code:
> > >
> > > Dim IP, domainName As String
> > > domainName = "yahoo.com"
> > >
> > > Try
> > > IP =
> > System.Net.Dns.GetHostByName(domainName).AddressList(0).ToString()
> > > Catch ex As Exception
> > > IP = "Not Valid"
> > > End Try
> > >
> > > Console.WriteLine(IP)
> > > System.Threading.Thread.Sleep(2000)
> > >
> > >
> > > When it has a resolvable domain, like yahoo.com it responds back
> instantly
> > > with the ip address. However, if there is a domain in there that does
> not
> > > exist, like blue2343.com, it takes upwards of 5 seconds to print "Not
> > Valid"
> > > to the screen. Why is that? and is there a way around it?
> > >
> > > Thanks,
> > >
> > > Scott
> > >
> > >
> >
> >
>
>