Filtered Stream Hangs

Dec 29, 2014 at 4:37 PM
My application is hanging when I try to use the filteredStream.

Here is my code:
        //ValueThatLtd tests
        TwitterCredentials.SetCredentials("my various keys",,,);

        // Access the filtered stream
        var filteredStream = Stream.CreateFilteredStream();
        filteredStream.AddTrack("justtesting");
        filteredStream.MatchingTweetReceived += (sender, args) => { Console.WriteLine(args.Tweet.Text); };
        filteredStream.StartStreamMatchingAllConditions();

And then it hangs. I am using version 0.9.3.4 of Tweetinvi within MVC project (from template) in Visual Studio 2013. I call the above code from a controller.

Any suggestions as to what might be wrong?

Best regards
Jan 5, 2015 at 9:55 AM
Try await filteredStream.StartStreamMatchingAllConditionAsync(); instead.
Apr 16, 2015 at 10:15 PM
Thank you thoze,
I had the same problem as WildAl but after using "StartStreamMatchingAllConditionAsync" function as you suggested, I am now able to get the tweets, however the application is freezing and I can't click on any other button such as "Stop Stream".

I tried to use "DoEvents" method but to no avail.
Also I coudn't use the keyword "await" since it is not available in Visual Studio 2010 which I have.

Any other suggestions?

By the way I use VB.net code:
    Sub Stream_FilteredStream()
        filteredStream = Stream.CreateFilteredStream()
        filteredStream.AddTrack("ladygaga")
        AddHandler filteredStream.MatchingTweetReceived, AddressOf MatchedTweetReceivedEvent
        filteredStream.StartStreamMatchingAllConditionsAsync()
    End Sub
    Sub MatchedTweetReceivedEvent(sender As Object, e As Tweetinvi.Core.Events.EventArguments.MatchedTweetReceivedEventArgs)
        lstTweets.Items.Add(e.Tweet.Text)
        Application.DoEvents()
    End Sub
Apr 19, 2015 at 2:22 AM
Hi,

You can either use the async method as suggested or create a Thread/BackgroundTask that you "listen" in your main (UI) thread in order to update your UI.
Your issue is a Thread issue not a Tweetinvi issue.

Linvi