Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.begingetresponse.aspx" rel="noreferrer">BeginGetResponse</a> is the method you need. It allows you to read the response stream incrementally:</p> <pre><code>class Program { static void Main(string[] args) { WebRequest request = WebRequest.Create("http://stream.twitter.com/spritzer.json"); request.Credentials = new NetworkCredential("username", "password"); request.BeginGetResponse(ar =&gt; { var req = (WebRequest)ar.AsyncState; // TODO: Add exception handling: EndGetResponse could throw using (var response = req.EndGetResponse(ar)) using (var reader = new StreamReader(response.GetResponseStream())) { // This loop goes as long as twitter is streaming while (!reader.EndOfStream) { Console.WriteLine(reader.ReadLine()); } } }, request); // Press Enter to stop program Console.ReadLine(); } } </code></pre> <p>Or if you feel more comfortable with <a href="http://msdn.microsoft.com/en-us/library/system.net.webclient%28VS.80%29.aspx" rel="noreferrer">WebClient</a> (I personnally prefer it over WebRequest):</p> <pre><code>using (var client = new WebClient()) { client.Credentials = new NetworkCredential("username", "password"); client.OpenReadCompleted += (sender, e) =&gt; { using (var reader = new StreamReader(e.Result)) { while (!reader.EndOfStream) { Console.WriteLine(reader.ReadLine()); } } }; client.OpenReadAsync(new Uri("http://stream.twitter.com/spritzer.json")); } Console.ReadLine(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload