searchasync example to replace non async search + foreach

Aug 4, 2014 at 9:56 AM
Hi Linvi,

First of all thank you very much for this AMAZING and SIMPLE Twitter API. It's absolutely brilliant! I am porting your whole API as a vvvv plugin dll. vvvv is a visual programming language similar to MAX/MSP or PURE DATA and is used mostly by creative coders and digital artists, it's also similar to OPENFRAMEWORKS.CC and TOUCHDESIGNER. Anyways I am making the ultimate vvvv twitter plug in which is effectively porting all features of your api to a vvvv plugin. I have had amazing success doing so and managed to port the whole search functionality but since vvvv is real-time coding I am looking at ASYNC search function to improve the plug in responsiveness.

SO, I am having trouble changing the twitter search function to async. I do apologise as I am not the best c# dev and i understand my lack of asynchronous c# programming doesn't help.
I am looking for an example of searchAsync function.

What i have is this (it works as it stands):
After defining some search parameters... I do this:
var tweets = Search.SearchTweets(searchParameter);
foreach(var tweet in tweets){
//DO LOTS OF STUFF, essentially populate a bunch of lists i have created with all tweet texts, //tweet author name, etc...

To change it to async search i try and do this...
Task<list<ITweet>> tweets = SearchAsync.SearchTweets(searchParameter);
or even simply the same: var tweets = SearchAsync.SearchTweets(searchParameter);

BUT THEN how do I loop through all results??? I am just simply trying to recreate the: foreach(var tweet in tweets){//DO THIS}

Is it just???
if(tweets!=null){//DO THIS}

Doesn't seem to work, effectively i am just trying to recreate the foreach but for async search function... If you could provide me with an example it would be much appreciated! Thank you again for everything. Peace
Aug 4, 2014 at 8:03 PM
Hi again, not sure I asked my question correctly: here is a much simpler version of it (as I realise what I am trying to do might not be possible):

Is it possible to fire an event every time a new tweet is found by a search or searchAsync function? Is it possible, if I search for 100 tweets to get a event every time a new tweet data is received, not just at the end of finding all 100 tweets? Do I have to wait anyway for the data of 100 tweets ALWAYS? Sorry if this sounds like a basic question.

If it is possible to do that, could anyone show a quick example?
Aug 4, 2014 at 11:25 PM
Hi there,

I am not sure what you meant by your first question.
For the second one, you want to use the FilteredStream.
var filteredStream = Stream.CreateFilteredStream();
filteredStream.MatchingTweetReceived += (sender, args) => 
    // Tweet Received!