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.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" <no@.direct.email> wrote in message
news:401B0E42.3A4D549E@.direct.email...
> 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.
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:#0T6qXB6DHA.1632@.TK2MSFTNGP12.phx.gbl...
> 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" <no@.direct.email> wrote in message
> news:401B0E42.3A4D549E@.direct.email...
> > 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.
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" <kevin@.takempis.com> wrote in message
news:OznQqhB6DHA.3308@.TK2MSFTNGP11.phx.gbl...
> 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:#0T6qXB6DHA.1632@.TK2MSFTNGP12.phx.gbl...
> > 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" <no@.direct.email> wrote in message
> > news:401B0E42.3A4D549E@.direct.email...
> > > 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.
> 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:O4UfnND6DHA.2656@.TK2MSFTNGP11.phx.gbl...
> 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" <kevin@.takempis.com> wrote in message
> news:OznQqhB6DHA.3308@.TK2MSFTNGP11.phx.gbl...
> > 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:#0T6qXB6DHA.1632@.TK2MSFTNGP12.phx.gbl...
> > > 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" <no@.direct.email> wrote in message
> > > news:401B0E42.3A4D549E@.direct.email...
> > > > 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.
> >
Thursday, March 22, 2012
Thread accessing session variables?
Labels:
access,
accessing,
application,
applicationstate,
asp,
checks,
itthe,
net,
periodically,
session,
spin,
states,
variables
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment