Thread accessing session variables?

Discussion in 'ASP .Net' started by Bruce W.1, Jan 31, 2004.

  1. Bruce W.1

    Bruce W.1 Guest

    I need to spin of a thread that periodically checks the Application
    state. How can a thread access Application or Session states? Send it
    the httpContext?

    Thanks for your help.
    Bruce W.1, Jan 31, 2004
    #1
    1. Advertising

  2. The httpcontext is owned by the main thread so you will need to send in a
    reference to the object to the thread. Here is an example:
    function(System.Web.HttpContext Stream)

    {
    Stream.Response.Write("vlah");
    }
    call it like so
    function(HttpContext.Current);

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Bruce W.1" <> wrote in message
    news:...
    > I need to spin of a thread that periodically checks the Application
    > state. How can a thread access Application or Session states? Send it
    > the httpContext?
    >
    > Thanks for your help.
    Alvin Bruney [MVP], Jan 31, 2004
    #2
    1. Advertising

  3. I don't think this will work. If the thread is running separately from the
    main Page execution thread, the Page may have already been processed, in
    which case the Response and Request would not be available.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:#...
    > The httpcontext is owned by the main thread so you will need to send in a
    > reference to the object to the thread. Here is an example:
    > function(System.Web.HttpContext Stream)
    >
    > {
    > Stream.Response.Write("vlah");
    > }
    > call it like so
    > function(HttpContext.Current);
    >
    > --
    > Regards,
    > Alvin Bruney [ASP.NET MVP]
    > Got tidbits? Get it here...
    > http://tinyurl.com/3he3b
    > "Bruce W.1" <> wrote in message
    > news:...
    > > I need to spin of a thread that periodically checks the Application
    > > state. How can a thread access Application or Session states? Send it
    > > the httpContext?
    > >
    > > Thanks for your help.

    >
    >
    Kevin Spencer, Jan 31, 2004
    #3
  4. Right. I didn't consider that context. In that case the main thread would
    need to wait on the worker thread to be finished.

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Kevin Spencer" <> wrote in message
    news:...
    > I don't think this will work. If the thread is running separately from the
    > main Page execution thread, the Page may have already been processed, in
    > which case the Response and Request would not be available.
    >
    > --
    > HTH,
    > Kevin Spencer
    > .Net Developer
    > Microsoft MVP
    > Big things are made up
    > of lots of little things.
    >
    > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    > news:#...
    > > The httpcontext is owned by the main thread so you will need to send in

    a
    > > reference to the object to the thread. Here is an example:
    > > function(System.Web.HttpContext Stream)
    > >
    > > {
    > > Stream.Response.Write("vlah");
    > > }
    > > call it like so
    > > function(HttpContext.Current);
    > >
    > > --
    > > Regards,
    > > Alvin Bruney [ASP.NET MVP]
    > > Got tidbits? Get it here...
    > > http://tinyurl.com/3he3b
    > > "Bruce W.1" <> wrote in message
    > > news:...
    > > > I need to spin of a thread that periodically checks the Application
    > > > state. How can a thread access Application or Session states? Send

    it
    > > > the httpContext?
    > > >
    > > > Thanks for your help.

    > >
    > >

    >
    >
    Alvin Bruney [MVP], Jan 31, 2004
    #4
  5. > Right. I didn't consider that context. In that case the main thread would
    > need to wait on the worker thread to be finished.


    That would do it. However, it would most probably also eliminate the benefit
    that the poster was trying to obtain by using a separate thread. Possibly
    not.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:...
    > Right. I didn't consider that context. In that case the main thread would
    > need to wait on the worker thread to be finished.
    >
    > --
    > Regards,
    > Alvin Bruney [ASP.NET MVP]
    > Got tidbits? Get it here...
    > http://tinyurl.com/3he3b
    > "Kevin Spencer" <> wrote in message
    > news:...
    > > I don't think this will work. If the thread is running separately from

    the
    > > main Page execution thread, the Page may have already been processed, in
    > > which case the Response and Request would not be available.
    > >
    > > --
    > > HTH,
    > > Kevin Spencer
    > > .Net Developer
    > > Microsoft MVP
    > > Big things are made up
    > > of lots of little things.
    > >
    > > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    > > news:#...
    > > > The httpcontext is owned by the main thread so you will need to send

    in
    > a
    > > > reference to the object to the thread. Here is an example:
    > > > function(System.Web.HttpContext Stream)
    > > >
    > > > {
    > > > Stream.Response.Write("vlah");
    > > > }
    > > > call it like so
    > > > function(HttpContext.Current);
    > > >
    > > > --
    > > > Regards,
    > > > Alvin Bruney [ASP.NET MVP]
    > > > Got tidbits? Get it here...
    > > > http://tinyurl.com/3he3b
    > > > "Bruce W.1" <> wrote in message
    > > > news:...
    > > > > I need to spin of a thread that periodically checks the Application
    > > > > state. How can a thread access Application or Session states? Send

    > it
    > > > > the httpContext?
    > > > >
    > > > > Thanks for your help.
    > > >
    > > >

    > >
    > >

    >
    >
    Kevin Spencer, Jan 31, 2004
    #5
    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. subrahmanya raju via .NET 247

    accessing session variables in a asp.net module

    subrahmanya raju via .NET 247, Jun 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,260
    Craig Deelsnyder
    Jun 26, 2004
  2. =?Utf-8?B?bW9oeW5lZW5t?=

    Accessing Session variables from custom class

    =?Utf-8?B?bW9oeW5lZW5t?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    5,568
    =?Utf-8?B?bW9oeW5lZW5t?=
    Oct 8, 2004
  3. John

    Accessing session from thread

    John, Nov 25, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    396
  4. Michael
    Replies:
    3
    Views:
    1,142
    Jim Cheshire
    Dec 30, 2005
  5. dwok
    Replies:
    7
    Views:
    697
    Hal Rosser
    Mar 4, 2005
Loading...

Share This Page