Use a static method / class?
-
Hi, I am in the middle of writing an ASP.Net program that will hand off a software key when the Web Server is called. I am receiving information from the caller in a "Query String" and saving it in a common class. After I have saved all the Query Strings, I am calling a Web Service to generate the key, using properties in the common class. If I successfully generate a key, I save the properties in the common class and the key to a SQL database on the server. My question is should I use a static class or should I instantiate a new instance of the class? I'm concerned about the properties getting overlaid by the next caller before the key is generate and the information about the buyer is written to the SQL database. At least hopefully thinking that I will be selling that much software ;) Thank you,
Glenn
-
Hi, I am in the middle of writing an ASP.Net program that will hand off a software key when the Web Server is called. I am receiving information from the caller in a "Query String" and saving it in a common class. After I have saved all the Query Strings, I am calling a Web Service to generate the key, using properties in the common class. If I successfully generate a key, I save the properties in the common class and the key to a SQL database on the server. My question is should I use a static class or should I instantiate a new instance of the class? I'm concerned about the properties getting overlaid by the next caller before the key is generate and the information about the buyer is written to the SQL database. At least hopefully thinking that I will be selling that much software ;) Thank you,
Glenn
-
Hi, I am in the middle of writing an ASP.Net program that will hand off a software key when the Web Server is called. I am receiving information from the caller in a "Query String" and saving it in a common class. After I have saved all the Query Strings, I am calling a Web Service to generate the key, using properties in the common class. If I successfully generate a key, I save the properties in the common class and the key to a SQL database on the server. My question is should I use a static class or should I instantiate a new instance of the class? I'm concerned about the properties getting overlaid by the next caller before the key is generate and the information about the buyer is written to the SQL database. At least hopefully thinking that I will be selling that much software ;) Thank you,
Glenn
You can use a thread-safe Singleton class like this:
public sealed class Singleton {
private static Singleton _instance = null;
private static readonly object singletonLock = new object();private Singleton() {} public static Singleton Instance { get { lock (singletonLock) { if (\_instance == null) { \_instance = new Singleton(); } return \_instance; } } }
}
"Don't confuse experts with facts" - Eric_V
-
Hi, I am in the middle of writing an ASP.Net program that will hand off a software key when the Web Server is called. I am receiving information from the caller in a "Query String" and saving it in a common class. After I have saved all the Query Strings, I am calling a Web Service to generate the key, using properties in the common class. If I successfully generate a key, I save the properties in the common class and the key to a SQL database on the server. My question is should I use a static class or should I instantiate a new instance of the class? I'm concerned about the properties getting overlaid by the next caller before the key is generate and the information about the buyer is written to the SQL database. At least hopefully thinking that I will be selling that much software ;) Thank you,
Glenn