/// <summary>
        /// Chrome's message-loop Window isn't created synchronously, so this may not find it.
        /// If so, you need to wait and try again later.
        /// </summary>
        public static bool TryFindHandle(IntPtr window, out IntPtr chromeWidgetHostHandle)
        {
            var          windowHandleInfo          = new ChromeWidgetHandleFinder(window);
            const string chromeWidgetHostClassName = "Chrome_RenderWidgetHostHWND";

            chromeWidgetHostHandle = windowHandleInfo.FindDescendantByClassName(chromeWidgetHostClassName);
            return(chromeWidgetHostHandle != IntPtr.Zero);
        }
 /// <summary>
 /// Asynchronously wait for the Chromium widget window to be created for the given ChromiumWebBrowser,
 /// and when created hook into its Windows message loop.
 /// </summary>
 /// <param name="interceptor">The interceptor.</param>
 /// <param name="window">The browser window to intercept Windows messages for.</param>
 /// <param name="framelessOptions">The frameless options.</param>
 /// <param name="forwardAction">This action will be called whenever a Windows message is received.</param>
 internal static void Setup(ChromeWidgetMessageInterceptor interceptor, IntPtr window, IFramelessOptions framelessOptions, Action <Message> forwardAction)
 {
     Task.Run(() =>
     {
         try
         {
             bool foundWidget = false;
             while (!foundWidget)
             {
                 if (ChromeWidgetHandleFinder.TryFindHandle(window, out var chromeWidgetHostHandle))
                 {
                     foundWidget = true;
                     interceptor = new ChromeWidgetMessageInterceptor(window, chromeWidgetHostHandle, framelessOptions, forwardAction);
                 }
                 else
                 {
                     // Chrome hasn't yet set up its message-loop window.
                     Thread.Sleep(10);
                 }
             }
         }
         catch { }
     });
 }