سؤال

I am using an unbounded blocking collection using the ConcurrentQueue as the underlying collection as one of the main components of my program.
I am looking at a good way to collect statistics about the consumption behaviour of the blocking collection, e.g. the maximum number of items which were inside the queue during the day or when the blocking collection resizes itself when the queue builts up.
Have I missed something or would I need to write an inherited class which overrides some methods, so that I can add more usage statistics to it?

هل كانت مفيدة؟

المحلول

You haven't missed anything. You'd have to implement this yourself. An inherited class probably won't help because none of BlockingCollection's methods are virtual.

Instead, you would have to write a wrapper and always access the collection through that wrapper. Alternatively, you could spawn a little thread that regularly polls the collection and reports its current state.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top