Created
April 29, 2010 05:43
-
-
Save johnsheehan/383198 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
using System.IO; | |
using System.Text; | |
using System.Diagnostics; | |
using System.Threading; | |
namespace LongPolling | |
{ | |
class MainClass | |
{ | |
public static void Main (string[] args) | |
{ | |
var http = (HttpWebRequest)WebRequest.Create("http://chirpstream.twitter.com/2b/user.json"); | |
http.Method = "GET"; | |
http.Credentials = new NetworkCredential("twitterusername", "twitterpassword"); | |
http.Timeout = -1; | |
var response = http.GetResponse(); | |
var stream = response.GetResponseStream(); | |
StreamReader sr = new StreamReader(stream); | |
Stopwatch watch = new Stopwatch(); | |
watch.Start(); | |
while (true) { | |
var line = sr.ReadLine(); | |
Console.WriteLine ("{0}: {1}", watch.Elapsed.TotalSeconds, line); | |
Thread.Sleep(1000); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment