Пример #1
0
        // Fully releases all managed resources associated with this request, including
        // the HttpContext, WebSocketContext, principal, worker request, etc.
        public void Destroy()
        {
            Debug.Trace("RootedObjects", "Destroy");

            // 'isDestroying = true' means that we'll release the implicit 'this' ref in _requestActivityIdRefCount
            using (WithinTraceBlock(isDestroying: true)) {
                try {
                    ReleaseHttpContext();
                    ReleaseWebSocketPipeline();
                    ReleaseWorkerRequest();
                    ReleasePrincipal();

                    // need to raise OnPipelineCompleted outside of the ThreadContext so that HttpContext.Current, User, etc. are unavailable
                    RaiseOnPipelineCompleted();

                    PerfCounters.DecrementCounter(AppPerfCounter.REQUESTS_EXECUTING);
                }
                finally {
                    if (_handle.IsAllocated)
                    {
                        _handle.Free();
                    }
                    Pointer = IntPtr.Zero;
                    HttpRuntime.DecrementActivePipelineCount();

                    AspNetEventSource.Instance.RequestCompleted();
                }
            }
        }