468,252 Members | 1,475 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,252 developers. It's quick & easy.

Session Variables and Static Variables

I have found it very easy to have a Helper class that has static
members which access Session Variables. For example:

public class HelperClass
{
public static doCustomer CurrentCustomer
{
get
{
if(HttpContext.Current.Session["Current_Customer"] == null)
CurrentCustomer = new doCustomer();

return (doCustomer)
HttpContext.Current.Session["Current_Customer"];
}
set
{
HttpContext.Current.Session["Current_Customer"] = value;
}
}
}

Is this thread safe? Will each user of the Application still have his
own instance of doCustomer, even though it is accessed via an
Application Wide static member? What is the best practice regarding
Thread Safety, Session Management and Static Members?

Thanks

Mar 23 '06 #1
1 1419
Anybody?

Mar 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by William LaMartin | last post: by
6 posts views Thread by Just D | last post: by
8 posts views Thread by Joe Abou Jaoude | last post: by
1 post views Thread by aliendolphin | last post: by
15 posts views Thread by Jason | last post: by
9 posts views Thread by Randy | last post: by
5 posts views Thread by Sean | last post: by
1 post views Thread by nicepg | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.