I have a web project wherein I have various functions that either add values to a series of lists that are defined as public static (so as to have them essentially act as global variables) or read from them.
The function that adds data to the list reads from a stream, various things happen and then when the user clicks a button the list is read and for each value contained therein an action is performed.
Everything works fine except when concurrent users are accessing the web page….in this instance the data that is stored in the lists is merged with the data that is created as a result of user interaction.
So the question is how can I preserve the ability for a list to be read from/written to from different functions without encountering concurrency issues? I can’t find a way to create/populate the lists within one function and then make it available to others on the page.
Thanks
Store the values in the Session, instead of static lists. As you found out, a static variable is shared between all users of the site.