- There is a class representing a certain API functionality. In the class code, there is a counter that changes after each call to one of the API methods. The counter determines the number of items received when calling the API method and is used for "internal consumption".
- If you call methods from different threads, the value of the counter will not be relevant.
- There is an idea to implement the counter as a dictionary.
Details There is an API for VK . I compile from modified sources. The essence of the changes is that each method call that receives a list of something, for example a list of message objects, from the json response, stores the TOTAL number of all messages in the counter. It is necessary for the self-written methods of the GetAll * type to work, which call the original API method several times, with the necessary offset, since Contact API does not allow you to get everything in one request. The counter is needed to determine the required number of calls.
But there is one moment. I would like to leave the possibility to get the value of this counter outside the API methods. The only alternative I can see is adding a variable like "out int totalCount" to each method of the original API, which is not good.
How to implement it correctly?
Or perhaps there is another, more successful way to solve such problems?
IEnumerable<T>- Pavel Hritonenko