Showing posts with label periodically. Show all posts
Showing posts with label periodically. Show all posts

Thursday, March 22, 2012

Thread abort error - REVISITED

I'm periodically getting "Thread Abort Error" errors thown from my web
app. My app will throw like 5 of these and will work normally again.
I'm thinking it is because my worker process was recycling so it
aborted all the threads. My question is, How can I stop it?Don't put any code after Response.Redirect(). That's it. Those Thread
Abort Exceptions will go away.

If you have so much as a return statement after a
Response.Redirect(?,true);, you'll run the risk of seeing these
exceptions. Regardless of what you do, you shouldn't be sweating them.
They're completely harmless.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

--
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Thread abort error - REVISITED

I'm periodically getting "Thread Abort Error" errors thown from my web
app. My app will throw like 5 of these and will work normally again.
I'm thinking it is because my worker process was recycling so it
aborted all the threads. My question is, How can I stop it?Don't put any code after Response.Redirect(). That's it. Those Thread
Abort Exceptions will go away.
If you have so much as a return statement after a
Response.Redirect(?,true);, you'll run the risk of seeing these
exceptions. Regardless of what you do, you shouldn't be sweating them.
They're completely harmless.
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Thread accessing session variables?

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