"Joseph Geretz" <jg*****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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
}
}
--
Anthony Jones - MVP ASP/ASP.NET