public static void DisposeAndClearHandle(ref SafeWinHttpHandle safeHandle)
 {
     if (safeHandle != null)
     {
         safeHandle.Dispose();
         safeHandle = null;
     }
 }
        // Important: WinHttp API calls should not happen while another WinHttp call for the same handle did not
        // return. During finalization that was not initiated by the Dispose pattern we don't expect any other WinHttp
        // calls in progress.
        protected override bool ReleaseHandle()
        {
            if (_parentHandle != null)
            {
                _parentHandle.DangerousRelease();
                _parentHandle = null;
            }

            return(WinHttpCloseHandle(handle));
        }
        public void SetParentHandle(SafeWinHttpHandle parentHandle)
        {
            Debug.Assert(_parentHandle == null);
            Debug.Assert(parentHandle != null);
            Debug.Assert(!parentHandle.IsInvalid);

            bool ignore = false;

            parentHandle.DangerousAddRef(ref ignore);

            _parentHandle = parentHandle;
        }
 private static extern bool WinHttpGetProxyForUrl(
     SafeWinHttpHandle sessionHandle, string url,
     ref WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions,
     out WINHTTP_PROXY_INFO proxyInfo);