I’m using a Queue<T> for caching video. The idea is to fill it with data (Enqueue), start playing (Dequeue) and fill back continously as data arrives. Can I do the filling back part from a background thread?
I’m using a Queue<T> for caching video. The idea is to fill it with
Share
It sounds like you’re looking for a producer/consumer queue. You can do this using
Queue<T>, but you’ll need to add locking to make sure you never access the queue from multiple threads concurrently.If you’re using .NET 4, Parallel Extensions makes this much easier with
IProducerConsumerCollection<T>andBlockingCollection<T>which do all the hard work for you.