I'm trying to do something a bit outside the box here and I'm getting the kind of hit-and-miss results that make think it's a threading issue. 

We have an ASP.NET 4 app where want to log each page request in the database with some session info. We also want to see how long each page took to generate, so we have base page that all pages in the app derive from and we override it's OnUnload event. In that handler we get the page generation time from: 

```
DateTime.Now.Subtract(HttpContext.Current.Timestamp).TotalSeconds

```

this works. But then we decided to try it async; maybe the page could be delivered faster if the client didn't have to wait on the insert of that log record. So I tried something like this:

```
ThreadPool.QueueUserWorkItem(new WaitCallback(LogPageRequest));

```

But as I said, sometimes it works, sometimes it doesn't. Is the server killing off my worker thread because the request is finished? Is there a better way to do this?