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

  • Thread starter Thread starter Joseph Geretz
  • Start date Start date
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 -
 
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
}
}
 
Back
Top