| title | IHttpContext::GetCurrentExecutionStats Method |
|---|---|
| description | Learn how the IHttpContext::GetCurrentExecutionStats method retrieves the execution statistics for the current context. |
| ms.date | 10/07/2016 |
| ms.assetid | 583768f4-5b0d-25af-df8d-3f34126663ca |
Retrieves the execution statistics for the current context.
virtual HRESULT GetCurrentExecutionStats(
DWORD* pdwNotification,
DWORD* pdwNotificationStartTickCount = NULL,
PCWSTR* ppszModule = NULL,
DWORD* pdwModuleStartTickCount = NULL,
DWORD* pdwAsyncNotification = NULL,
DWORD* pdwAsyncNotificationStartTickCount = NULL
) const = 0; pdwNotification
A pointer to a DWORD that contains the current notification.
pdwNotificationStartTickCount
A pointer to a DWORD that contains the tick count for the start of the current notification.
ppszModule
A pointer to a string that contains the name of the current module.
pdwModuleStartTickCount
A pointer to a DWORD that contains the tick count for the start of the current module.
pdwAsyncNotification
A pointer to a DWORD that contains the current asynchronous notification.
pdwAsyncNotificationStartTickCount
A pointer to a DWORD that contains the tick count for the start of an asynchronous notification.
An HRESULT. Possible values include, but are not limited to, those in the following table.
| Value | Description |
|---|---|
| NO_ERROR | Indicates that the operation was successful. |
| E_INVALIDARG | Indicates that a specified parameter is not valid. |
Developers can use the GetCurrentExecutionStats method to retrieve specific execution information for the current context. For example, the pdwNotification and pdwAsyncNotification parameters contain the values for the current synchronous or asynchronous notification, and the ppszModule parameter contains the name of the module for the current context.
Three of the return parameters, pdwModuleStartTickCount, pdwNotificationStartTickCount, and pdwAsyncNotificationStartTickCount, respectively, contain the tick counts for the start of the module and the start of the current synchronous and asynchronous notifications.
Note
The tick count is the number of milliseconds that have elapsed since the system was started. For more information about retrieving tick counts, see the GetTickCount method.
The following code example demonstrates how to create an HTTP module that performs the following tasks:
-
The module registers for the RQ_BEGIN_REQUEST, RQ_MAP_REQUEST_HANDLER, and RQ_SEND_RESPONSE notifications.
-
The module creates a CHttpModule class that contains OnBeginRequest, OnMapRequestHandler, and OnSendResponse methods.
-
When a Web client requests a URL, IIS calls the module's
OnBeginRequest,OnMapRequestHandler, andOnSendResponsemethods. Each of these methods calls a private method namedRetrieveExecutionStatsthat performs the following tasks:-
Retrieves the execution statistics by using the
GetCurrentExecutionStatsmethod and tests for an error. -
Creates a string that contains the tick count for the start of the current notification.
-
Pauses for one second.
-
Creates a string that contains the elapsed tick count from the start of the current notification.
-
Writes the execution statistics as an event to the application log of the Event Viewer.
-
-
The module removes the
CHttpModuleclass from memory and then exits.
[!code-cppIHttpContextGetCurrentExecutionStats#1]
Your module must export the RegisterModule function. You can export this function by creating a module definition (.def) file for your project, or you can compile the module by using the /EXPORT:RegisterModule switch. For more information, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.
You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.
| Type | Description |
|---|---|
| Client | - IIS 7.0 on [!INCLUDEwinvista] - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
| Server | - IIS 7.0 on [!INCLUDEwinsrv2008] - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 |
| Product | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100] |
| Header | Httpserv.h |