Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

New Post: Simple stream not stopping when asked

$
0
0
Hi Yossi,

I am pretty confident with the fact that your condition _Tweets.Count < iNumTweets is never met because I believe that the condition tweet.Text.StartsWith("RT") is very rare and consequently you'll have to wait a long time before it is met.

Once the condition is met your stream should stop.

Here is a simpler example that displays the first 5 tweets received from the stream before stopping the stream.
The example also provides an example of the StreamStopped event and how you should expect it to behave
SimpleStream stream = new SimpleStream("https://stream.twitter.com/1.1/statuses/sample.json");

stream.StreamStopped += (sender, args) =>
{
    if (args.Value == null)
    {
        Console.WriteLine("Stream stopped correctly");
    }
    else
    {
        Console.WriteLine("An error occured with the message : {0}", args.Value.Message);
    }
};

var i = 0;
stream.StartStream(token, tweet =>
{
    Console.WriteLine(tweet.Text);

    ++i;
    if (i == 5)
    {
        stream.StopStream();
    }
});
Please let me know if this helps.
Linvi

Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>