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. Advertisements

  2. Guest

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

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. Earl Teigrob

    Global Session Variables and Session State

    Earl Teigrob, Dec 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    4,965
    Alvin Bruney
    Dec 17, 2003
  2. Varangian

    Static and Session variables

    Varangian, Mar 27, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    491
    Varangian
    Mar 27, 2006
  3. SaravanaKumar
    Replies:
    6
    Views:
    9,929
    Tony Morris
    Oct 19, 2004
  4. =?Utf-8?B?Um9iSEs=?=
    Replies:
    4
    Views:
    5,870
    =?Utf-8?B?Um9iSEs=?=
    Apr 11, 2007
  5. Neviton
    Replies:
    9
    Views:
    662
    Alf P. Steinbach
    Sep 17, 2007
  6. Martin Wells

    Static inline functions with static local variables

    Martin Wells, Oct 6, 2007, in forum: C Programming
    Replies:
    10
    Views:
    918
    Army1987
    Oct 8, 2007
  7. Hicham Mouline
    Replies:
    5
    Views:
    2,742
    James Kanze
    Dec 19, 2008
  8. Jazzis
    Replies:
    2
    Views:
    437
    Jazzis
    Sep 23, 2003
Loading...