jango
Tue Feb 15 15:03:04 CST 2005
I see from youre code that you're closing the httpRequest object before
you're closing the StreamWriter.
How come? Could this result in the problems I'm seeing? (I'll check :-)
Jan
"Alvin Bruney [MVP]" wrote:
> here is my threaded code that i use. see if you are missing anything.
>
> strNumber =
> System.Text.RegularExpressions.Regex.Replace(strNumber,"\\D",string.Empty);
>
> // Create a new 'Uri' object with the specified string.
>
> Uri myUri =new
> Uri("
http://adp.infousa.com/fs?BAS_fssession=&BAS_vendor=0&bas_type=FADA&BAS_page=9&DAT_maxrecords=10&BAS_flag=2&BAS_flag2=1&SCH_origdb=FADP&sch_fullphone="
> + strNumber);
>
> // Creates an System.Net.HttpWebRequest with the specified URL.
>
> System.Net.HttpWebRequest myHttpWebRequest =
> (System.Net.HttpWebRequest)WebRequest.Create(myUri);
>
> myHttpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
> 5.1; Q312461; .NET CLR 1.0.3705)";
>
> HttpWebResponse res = (HttpWebResponse)myHttpWebRequest.GetResponse();
>
> StreamReader sr = new StreamReader(res.GetResponseStream(),
> System.Text.Encoding.UTF8);
>
> string pageContent = sr.ReadToEnd();
>
> res.Close();
>
> sr.Close();
>
>
>
> --
> Regards,
> Alvin Bruney [Microsoft MVP ASP.NET]
>
> [Shameless Author plug]
> The Microsoft Office Web Components Black Book with .NET
> Now Available @
http://www.lulu.com/owc
> ----------------------------------------------------------
>
>
> "Jan" <jango@newsgroup.nospam> wrote in message
> news:7FA85C40-D7F7-4FE8-AB88-72FD673B2040@microsoft.com...
> >I don't think I'm setting the useragent at all.
> >
> > Jan
> >
> >
> > "Alvin Bruney [MVP]" wrote:
> >
> >> It shouldn't. Are you setting the useragent correctly? How do you know it
> >> is
> >> hanging? Are there any exceptions?
> >>
> >> --
> >> Regards,
> >> Alvin Bruney [Microsoft MVP ASP.NET]
> >>
> >> [Shameless Author plug]
> >> The Microsoft Office Web Components Black Book with .NET
> >> Now Available @
http://www.lulu.com/owc
> >> ----------------------------------------------------------
> >>
> >>
> >> "Jan" <jango@newsgroup.nospam> wrote in message
> >> news:2E97DF71-056D-4B95-BC81-10AA68CA6D45@microsoft.com...
> >> > I've got a program accessing a HTTP service to get som XML data.
> >> >
> >> > The code receiveing the data looks something like this:
> >> > stream = new
> >> > StreamWriter(httpRequest.GetRequestStream(),Encoding.UTF8);
> >> > stream.Write(body);
> >> > stream.Close();
> >> >
> >> > The httpRequest is a HttpWebRequest object.
> >> >
> >> > This works fine from a single thread execution, but when I'm accessing
> >> > this
> >> > method on its own thread, the Close() method seems to hang.
> >> >
> >> > Any ideas as to what I'm doing wrong?
> >> >
> >> > Jan
> >> >
> >> > --
> >> > Do or die..
> >>
> >>
> >>
>
>
>