This project has moved and is read-only. For the latest updates, please go here.

Cancel getting filtered statuses

Feb 1, 2014 at 12:56 PM

I'm using the filtered statuses stream and would like to be able to cancel the listening process ASAP.
Currently i'm using the following code (form the documentation):
    (from strm in twitterCtx.Streaming
        where strm.Type == StreamingType.Filter &&
            strm.Track == "twitter"
        select strm)
    .StartAsync(async strm =>
        // Do Something
I could use a cancellation token within StartAsync but this would still wait until the next status is received (this could take a while when using a filter with low popularity).
Can this be refactored to cancel the listening process ASAP?
Feb 1, 2014 at 7:25 PM

The strm parameter in the StartAsync callback has a CloseStream() method that you can call. After the first response from Twitter, calling the callback, you can capture this variable and pass to any code that needs to call CloseStream().