G
Gaensh
HI,
I have a singleton pattern to acess my database the following is
the sample code use to implement singleton pattern
public class DataAccessHelper
{
private static DataAccessHelper instance;
/// <summary>
/// public property that can only get the single instance of this
class.
/// </summary>
public static DataAccessHelper GetInstance
{
get
{ // Support multithreaded applications through
// "Double checked locking" pattern which avoids
// locking every time the method is invoked
if(instance == null)
{
// Only one thread can obtain a mutex
Mutex useMutex = new Mutex(true);
useMutex.WaitOne();
if(instance == null)
instance = new DataAccessHelper();
useMutex.Close();
} return instance;
}
}
}
I am using this in my data layer and our application is 3 tier
application presentation is asp.net, business is webservice . ?
Q1. Does asp.net/webservice generate multithreaded scenario. ?
Q2. Does using mutex slowes the reponse time of the request. ?
Q3. Should singleton be used in asp.net scenario ?
Q4. Is ASP.Net / webservice is a multithreaded apllication ?
your feedback is very imporatant as the client feels that using
multithread scenario will not be encountered in asp.net/webservice and
using mutex will slow down the response of the request.
Thank you all in advance
I have a singleton pattern to acess my database the following is
the sample code use to implement singleton pattern
public class DataAccessHelper
{
private static DataAccessHelper instance;
/// <summary>
/// public property that can only get the single instance of this
class.
/// </summary>
public static DataAccessHelper GetInstance
{
get
{ // Support multithreaded applications through
// "Double checked locking" pattern which avoids
// locking every time the method is invoked
if(instance == null)
{
// Only one thread can obtain a mutex
Mutex useMutex = new Mutex(true);
useMutex.WaitOne();
if(instance == null)
instance = new DataAccessHelper();
useMutex.Close();
} return instance;
}
}
}
I am using this in my data layer and our application is 3 tier
application presentation is asp.net, business is webservice . ?
Q1. Does asp.net/webservice generate multithreaded scenario. ?
Q2. Does using mutex slowes the reponse time of the request. ?
Q3. Should singleton be used in asp.net scenario ?
Q4. Is ASP.Net / webservice is a multithreaded apllication ?
your feedback is very imporatant as the client feels that using
multithread scenario will not be encountered in asp.net/webservice and
using mutex will slow down the response of the request.
Thank you all in advance