Is an HttpHandler notified when it is released to the pool?

J

Joseph Geretz

If an HttpHandler is implementing IsReusable = true, is the instance
notitifed when it is actually released to the pool? Of course, each instance
is released to the pool when ProcessRequest terminates. I'm working on a
different design pattern though. In my architecture, all of my handlers
derive from a base super-handler class and I'd like to implement certain
behavior in the super-handler class to occur at transaction completion time.
For a non-pooled object this would happen when the class is disposed, for a
pooled object this would happen when the object is released to the pool. How
can I determine when this latter event, release to the pool, happens?

Thanks for your advice.

- Joseph Geretz -
 
A

Anthony Jones

Joseph Geretz said:
If an HttpHandler is implementing IsReusable = true, is the instance
notitifed when it is actually released to the pool? Of course, each
instance is released to the pool when ProcessRequest terminates. I'm
working on a different design pattern though. In my architecture, all of
my handlers derive from a base super-handler class and I'd like to
implement certain behavior in the super-handler class to occur at
transaction completion time. For a non-pooled object this would happen
when the class is disposed, for a pooled object this would happen when the
object is released to the pool. How can I determine when this latter
event, release to the pool, happens?

I'm not sure what you mean by a 'non-pooled object' being disposed. Even if
your super class implements IDisposable what would call it?

Consider this approach:-

public abstract class SuperHandler : IHttpHandler
{

private HttpContext myContext;
public HttpContext Context { get { return myContext; } }

public HttpResponse Response { get { return myContext.Response; } }
public HttpRequest Request { get { return myContext.Request; } }

protected abstract void InnerProcess();

public void ProcessRequest(HttpContext context)
{
myContext = context;
InnerProcess();
// Code here for when request complete
myContext = null;
}

public virtual bool IsReusable { get { return false; } }
}

public class Test : SuperHandler
{
protected override void InnerProcess()
{
// Do stuff
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top