davej Posted April 24, 2012 Share Posted April 24, 2012 So if I wanted to supply a common list of users who are logged in to all users what is the most efficient approach? A static class with a static arraylist? A small table in the database? Something else? Thanks Link to comment Share on other sites More sharing options...
boen_robot Posted April 24, 2012 Share Posted April 24, 2012 Since the data needs to persist between requests, while being the same for all users, a database table seems not simply the best, but pretty much the only solution. Link to comment Share on other sites More sharing options...
davej Posted April 24, 2012 Author Share Posted April 24, 2012 (edited) Well, it seems that static variables might be an alternative, but there is a concern about "thread safety" which is over my head. Setting or clearing a particular boolean in a static array might be thread safe but I would have doubts about using an arraylist or string or any multi-byte variable. Edited April 24, 2012 by davej Link to comment Share on other sites More sharing options...
boen_robot Posted April 24, 2012 Share Posted April 24, 2012 Last I checked, similarly to PHP, ASP.NET re-executes your whole code (the only difference from , say PHP, is that the code is compiled on first access), so a static variable wouldn't work. Link to comment Share on other sites More sharing options...
davej Posted April 28, 2012 Author Share Posted April 28, 2012 Well, I think one approach is to use application variables such as Application["user1"]. I am going to experiment with this. http://msdn.microsoft.com/en-us/library/ms178594.aspx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now