I adapted the following code from one I found online. Works ok but is not running continuously and pulling in new tweets. What do I need to change? Help appreciated.
private static void Stream_FilteredStreamExample()
{
SqlConnection conn = new SqlConnection(@"Data Source=********************");
conn.Open();
for (; ; )
{
try
{
var stream = Stream.CreateFilteredStream();
//stream.AddLocation(Geo.GenerateLocation(-180, -90, 180, 90));
stream.AddTweetLanguageFilter(Language.English);
stream.AddTrack("#TubeStrike");
var timer = Stopwatch.StartNew();
stream.MatchingTweetReceived += (sender, args) =>
{
var tweet = args.Tweet;
if (timer.ElapsedMilliseconds > 1000)
{
Console.WriteLine("{0}, {1}", tweet.IdStr, tweet.Text);
timer.Restart();
}
};
stream.StartStreamMatchingAllConditions();
}
catch (Exception ex)
{
Console.WriteLine("Exception: {0}", ex.Message);
}
}
}
You want to use the following code: