private static NativeMethods.REQUEST_NOTIFICATION_STATUS HandleRequest(IntPtr pInProcessHandler, IntPtr pvRequestContext) { IISHttpServer server = null; try { // Unwrap the server so we can create an http context and process the request server = (IISHttpServer)GCHandle.FromIntPtr(pvRequestContext).Target; server.IncrementRequests(); var context = server._iisContextFactory.CreateHttpContext(pInProcessHandler); ThreadPool.UnsafeQueueUserWorkItem(context, preferLocal: false); return(NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_PENDING); } catch (Exception ex) { server?._logger.LogError(0, ex, $"Unexpected exception in static {nameof(IISHttpServer)}.{nameof(HandleRequest)}."); return(NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_FINISH_REQUEST); } }