Observing the User Experience: A Practitioners Guide to User Research

SO FAR WE VE TREATED THE ISAPI DLL as a request dispatcher. Your ISAPI DLL receives requests and hands off the processing to the appropriate application DLL. Your ISAPI DLL is also the place to expose your ISAPI services.

ISAPI services allow developers to provide services to all their application DLLs. These might be global functions or shared global information such as session state, caches, or Perfmon counters. In this chapter we cover the basics of exposing an ISAPI service from your ISAPI DLL.

What to Put in Your ISAPI DLL

When your application is loaded by IIS, IIS locks your ISAPI DLL in memory. This makes ISAPI very efficient, but it adds some complexity to changing your ISAPI DLL. Changing your ISAPI DLL involves resetting IIS (which usually takes between 10 and 30 seconds) with an iisreset command.

The downside of changing your ISAPI DLL is that your server will be unable to process any incoming requests until the IIS service restarts and reloads your ISAPI. All requests that arrive before IIS is restarted will be completely lost. Therefore, it s recommended that you don t restart IIS often, which in turn means that you can t change your ISAPI DLL often.

For this reason, it makes sense to take advantage of ATL Server s separation between the application DLLs and the ISAPI DLL. The ISAPI DLL still has one unique advantage over the application DLLs. Application logic resides in the ATL Server thread pool in the form of worker threads. In this model, when a request comes in, the ISAPI DLL hands it off to an available worker thread. This thread processes the given request and then returns to the thread pool when it finishes processing. This means that data stored in your application DLL is request specific . Once a given request has been handled, the data in your thread will be reset.

The only way to store data that has the same lifetime as your application is to do so outside of the application DLL. The ISAPI DLL is perfect for many of these services.

Tip  

It s also possible to use a Windows Service to store data that will have the same lifetime as your application, as you can see in the PerfPersist sample included with Visual Studio .NET.

Категории