Webpage taking forever to load

Mar 8, 2014 at 12:39 PM
I'm building a webpage to show the time line of some twitter account and for now to display it in a label
the problem is when I use the code under in the page load the browser keep in the waiting status and never load the page I would really llike to know what is wrong and thanks in advance
 string consumerKey = //consumer key
        string consumerKeySecret = //consumer key secret 
        string accessToken = //access token 
        string accessTokenSecret = //access token secret 
        TwitterCredentials.Credentials = TwitterCredentials.CreateCredentials(accessToken, accessTokenSecret, consumerKey, consumerKeySecret);
        var sampleStream = Stream.CreateSampleStream();
        sampleStream.TweetReceived += (sender1, args) => { Label1.Text = (args.Tweet.Text); };
        sampleStream.StartStream();
Coordinator
Mar 8, 2014 at 1:39 PM
Hi there,

A sample stream is not something you can use to get the timeline of any user account. It basically retrieve 1% of all the tweets sent on Twitter.
If you want to get all the tweets from specific user accounts, you'll need to use the UserStream.

Concerning your issue, this behaviour is expected. When starting a stream it will retrieve all the tweets from Twitter until you call Stream.StopStream() or an Exception occurs.
You cannot use a stream in your loading, use it when the page is loaded and refresh your page with ajax and polling or websocket.

Also if you want to retrieve the tweets from a specific user timeline, you can use Timeline.GetUserTimeline();

Feel free to ask for more information if you need.
Hope this help.

Linvi
Mar 8, 2014 at 2:54 PM
thank you for replying,
and I have some other question how would you cal stop stream if it wont stop reading tweets ??
Coordinator
Mar 8, 2014 at 4:00 PM
Hi,

You can either call it from the TweetReceived event or if you cam the StartStream from a new thread you can invoke StopStream from a second thread.
Does that make sense?

Linvi