/// <summary>
        /// Call this function (from a subclass) as soon as the process is started.
        /// </summary>
        protected void StartDialogWatcher()
        {
            if (!Settings.AutoStartDialogWatcher || DialogWatcher != null)
            {
                return;
            }

            DialogWatcher = DialogWatcher.GetDialogWatcher(hWnd);
            DialogWatcher.IncreaseReferenceCount();
        }
        public static WatiN_IE setDialogWatcher(this WatiN_IE watinIe)
        {
            if (watinIe.isNull())
            {
                return(null);
            }
            if (watinIe.IE.DialogWatcher == null)
            {
                //set the value of IE.DialogWatcher with the current inproc IE dialogWatcher

                var dialogWatcher = DialogWatcher.GetDialogWatcher(Processes.getCurrentProcess().MainWindowHandle);
                var property      = PublicDI.reflection.getPropertyInfo("DialogWatcher", typeof(DomContainer));
                PublicDI.reflection.setProperty(property, watinIe.IE, dialogWatcher);

                dialogWatcher.CloseUnhandledDialogs = false;
            }
            return(watinIe);
        }