This sample demonstrates how to create and manage a worker thread pool to handle requests to this ISAPI extension so that the IIS thread pool is not depleted. This can be useful if your ISAPI takes a long time to process.
Important These samples are provided for educational purposes only. They are not intended to be used in a production environment, have not been tested in a production environment, and Microsoft does not provide technical support for them.
Sample Overview
Requirements
Location of the Source Code
Build and Install the Sample
Run the Sample
Sample Output
Helpdesk
IIS maintains a pool of threads to handle incoming HTTP requests. When all of these threads are in use, new requests will be rejected. If all the pool threads are in a wait state (for instance, running ISAPI dlls that are waiting for a query on a remote database to complete), IIS may reject incoming requests even if there is plenty of CPU power to handle them.
One way of avoiding this situation is to offload processing of these types of requests to a worker thread, releasing the IIS thread back to the pool so that it can be used for another request. This basic sample demonstrates how to implement this in an ISAPI dll.
to top
This sample requires the installation of the following software to function properly:
IIS samples are included in the IIS Software Developer Kit (SDK). You can download the IIS SDK from Platform SDK Update. You can view the SDK at MSDN Online. In the table of contents at MSDN Online, click Web Development, Server Technologies, Internet Information Services (IIS), SDK Documentation, Internet Information Services, Samples.
The following source code files are required for this sample:
File | Description |
---|---|
WorkerThread.sln | WorkerThread Visual Studio .NET solution file, required to build this sample in Visual Studio .NET. |
WorkerThread.vcproj | WorkerThread Visual Studio .NET C Project file, required to build this sample in Visual Studio .NET. |
WorkerThread.dsp, WorkerThread.dsw | WorkerThread Visual Studio 6.0 project files, required to build this sample in Visual Studio Version 6. |
WorkerThread.c | WorkerThread source module containing the code that implements the sample. |
WorkerThread.def | WorkerThread.dll definition containing code for creating the sample. |
MAKEFILE | WorkerThread makefile for command line compilation |
To build this sample using the Visual C++ IDE, the following steps must be performed:
To build and run this sample without using the Visual C++ IDE, the following steps must be performed:
C:\MySamples
, type the following at the command line:
cd /d c:\MySamples NMAKE All
To install this sample, the following steps must be performed:
C:\Samples
and copy the file to that folder.inetmgr
in the text box and click OK. Right-click on the Web
site where you want to create a virtual directory, click New, and click Virtual
Directory. In the Alias text box, type the name you want for your virtual directory, for
example, WorkerThread
. In the Directory text box, type the path to the
folder that contains your files.
In order to run this sample, follow the instructions listed below:
WorkerThread
, type
http://localhost/WorkerThread/WorkerThread.dll
in the Address bar
of IE.
The following output is displayed somewhere after you perform step 1 from Run the Sample.
Worker Thread Sample
Send Request (button)
After you click the Send Request button, the ISAPI extension creates its own thread pool and serves the page again. To watch what the ISAPI does, run it under a debugger.
to top
If here you do not find answers to your questions, visit the Microsoft Help and Support Web site.
Problem | Possible Solution |
---|---|
When building the dll, C++ or VB returns the a permissions error. | Once you have called the dll from your web page, your system considers it a loaded dll. You must unload it to build it again, either by unloading the ASP application or deleting the dll from system32\dllcache. |
When browsing to the dll, IE gives you a permissions error. | The folder and virtual directory must have Execute permissions set on them. |
© 1997-2002 Microsoft Corporation. All rights reserved.