Problem fixed via discussion on StackOverflow http://stackoverflow.com/questions/1883022/why-does-webresponse-never-end-when-reading-twitter-firehose-stream
FYI: needed to add a response.Abort() before the break, though others reported function working without the need for the Abort() call. On Dec 13, 9:31 pm, martimedia <duffym...@googlemail.com> wrote: > With the sample function below the program never returns from iDispose > WebResponse/StreamReader (TcpClient works fine): > > public void GetStatusesFromStream(string username, string password, > int nMessageCount) > { > WebRequest request = WebRequest.Create("http://stream.twitter.com/ > 1/statuses/sample.json"); > request.Credentials = new NetworkCredential(username, password); > > using (WebResponse response = request.GetResponse()) > { > using (var stream = response.GetResponseStream()) > { > using (var reader = new StreamReader(stream)) > { > while (!reader.EndOfStream) > { > Console.WriteLine(reader.ReadLine()); > > if (nMessageCount-- < 0) > break; > } > Console.WriteLine("Start iDispose"); > } > Console.WriteLine("Never gets here!!!"); > } > } > > Console.WriteLine("Done - press a key to exit"); > Console.ReadLine(); > > } > > I've raised the question at stackoverflow but with no solution so > far... > > http://stackoverflow.com/questions/1883022/why-does-webresponse-never...