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

Commented Issue: Encountering System.AggregateException with StartStreamMatchingAllConditions [2324]

$
0
0
Hi Linvi,

Having read a separate topic on the discussion forum about keeping streams alive (url: https://tweetinvi.codeplex.com/discussions/542898) where someone suggested using the code below to put the thread to sleep for 2 seconds and restart the stream matching the previously set conditions, I am encountering an System.AggregateException with the Tweetinvi.Streams.FilteredStream.StartStreamMatchingAllConditions() method.

The offending code:

```
TwitterCredentials.SetCredentials(_accessKey, _accessToken, _consumerKey, _consumerSecret);
_filteredStream = Stream.CreateFilteredStream();
_filteredStream.FilterTweetsToBeIn(Language.English);
_filteredStream.StreamStopped += (sender, args) =>
{
// Put the current Thread to sleep for 2 seconds
Thread.Sleep(2000);

// Restart Stream matching all conditions
_filteredStream.StartStreamMatchingAllConditions(); // <== exception here
};
_thread = new Thread(_filteredStream.StartStreamMatchingAllConditions);
_thread.Start();
```
I was thinking that this might be because there might be some scenario at runtime where the _thread has not been started yet and I am trying to put the thread to sleep in the lambda. I am unsure though - just speculating. I am not very experienced with the System.Tasks library!

And the Exception details:

```
Exception: System.AggregateException

Message: One or more errors occurred.

StackTrace: at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Tweetinvi.Core.Helpers.SynchronousInvoker.ExecuteSynchronously(Task task)
at Tweetinvi.Streams.FilteredStream.StartStreamMatchingAllConditions()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

InnerException: System.Exception

Message: Value cannot be null.
Parameter name: source

StackTrace: at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Tweetinvi.Streams.FilteredStream.<StartStreamMatchingAllConditionsAsync>d__24.MoveNext()
```

Whilst searching the forum, I noticed that there was already an issue earlier this year that was potentially the same issue as I am experiencing but it seems that you shipped out several bug fixes for this already in recent versions of the library.

I was hoping you could enlighten me as to why this Exception is occuring and what is referred to by "Value cannot be null, Parameter name: source" - is this related to an internal function relating to the System.Task library?

Thank you in advance
A
Comments: ** Comment from web user: adaam2 **

/ Mighta been a 429 - can't remember! The actual issue was that I had IISExpress and IIS running at the same time, so therefore multiple connections


Viewing all articles
Browse latest Browse all 4126

Trending Articles