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

Edited Issue: Stream : StreamState Concurrency [2566]

$
0
0
FROM : https://tweetinvi.codeplex.com/discussions/635987

When invoking StopStream, the stream is stopped directly. But the async task keeps running as it is waiting for a message from the Stream in another Thread.

At such point if the async task closes after the user has invoked the StartStream again, the Stream is invoking StopStream() another time.

// Code to reproduce

``` C#
// STREAM 1
var fs = Stream.CreateFilteredStream();

fs.StreamStarted += (sender, args) =>
{
Console.WriteLine("Stream 1 Started!");
};

fs.MatchingTweetReceived += (sender, args) =>
{
Console.WriteLine("Stream 1 : " + args.Tweet);
};
fs.AddTrack("lady gaga");
fs.StartStreamMatchingAllConditionsAsync();

// STREAM 2
var fs2 = Stream.CreateFilteredStream();
fs2.StreamStarted += (sender, args) =>
{
Console.WriteLine("Stream 2 Started!");
};

fs2.StreamStopped += (sender, args) =>
{
Console.WriteLine("Stream 2 Stopped!");
};

fs2.MatchingTweetReceived += (sender, args) =>
{
Console.WriteLine("Stream 2 : " + args.Tweet);
};

fs2.AddTrack("fqomnfoqmfqoif");

var resetTimer = new System.Timers.Timer(20000);
resetTimer.Elapsed += (o, eventArgs) =>
{
fs2.StopStream();
//Add a high volume keyword
fs2.AddTrack("lady gaga");
resetTimer.Stop();
fs2.StartStreamMatchingAllConditions();
};

resetTimer.Start();
fs2.StartStreamMatchingAllConditions();
```

Viewing all articles
Browse latest Browse all 4126

Trending Articles



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