Session Variables and Static Variables

Discussion in 'ASP .Net' started by cobus.lombard@gmail.com, Mar 23, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Guest

    Anybody?
    , Mar 26, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Varangian

    Static and Session variables

    Varangian, Mar 27, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    382
    Varangian
    Mar 27, 2006
  2. SaravanaKumar
    Replies:
    6
    Views:
    9,366
    Tony Morris
    Oct 19, 2004
  3. Neviton
    Replies:
    9
    Views:
    446
    Alf P. Steinbach
    Sep 17, 2007
  4. Martin Wells

    Static inline functions with static local variables

    Martin Wells, Oct 6, 2007, in forum: C Programming
    Replies:
    10
    Views:
    695
    Army1987
    Oct 8, 2007
  5. Hicham Mouline
    Replies:
    5
    Views:
    2,351
    James Kanze
    Dec 19, 2008
Loading...

Share This Page