Storing an object to use in multiple classes

Posted by Aaron Sanders on Stack Overflow See other posts from Stack Overflow or by Aaron Sanders
Published on 2010-03-23T20:43:56Z Indexed on 2010/03/23 20:53 UTC
Read the original article Hit count: 324

Filed under:
|
|

I am wondering the best way to store an object in memory that is used in a lot of classes throughout an application.

Let me set up my problem for you:

We have multiple databases, 1 per customer. We also have a master table and each row is detailed information about the databases such as database name, server IP it's located and a few config settings.

I have an application that loops through those multiple databases and runs some updates on them. The settings I mentioned above are updated each loop iteration into memory. The application then runs through series of processes that include multiple classes using this data. The data never changes during the processes, only during the loop iteration.

The variables are related to a customer, so I have them stored in a customer class. I suppose I could make all of the members shared or should I use a singleton for the customer class? I've never actually used a singleton, only read they are good in this type of situation. Are there better solutions to this type of scenario?

Also, I could have plans for this application to be multithreaded later.

Sorry if this is confusing. If you have questions, let me know and I will answer them.

Thanks for your help.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about .net-2.0