Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Thread accessing session variables?

Reply
Thread Tools

Thread accessing session variables?

 
 
Bruce W.1
Guest
Posts: n/a
 
      01-31-2004
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.
 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      01-31-2004
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.



 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      01-31-2004
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.

>
>



 
Reply With Quote
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      01-31-2004
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.

> >
> >

>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      01-31-2004
> 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.
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Timeout problems-web.confg session state and IIS session s =?Utf-8?B?Um9iSEs=?= ASP .Net 4 04-11-2007 04:52 PM
Accessing Session variables when using SQL Server for Session state Michael ASP .Net 3 12-30-2005 07:56 PM
Accessing session from thread John ASP .Net 2 11-26-2005 04:02 PM
Session State - What does it take to establish one single ASP.NET session per "browser session" Jeff Smythe ASP .Net 3 01-02-2004 04:10 AM
Accessing ASP Session from ASP.NET via Session cookie Dax Westerman ASP General 1 08-19-2003 11:10 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57