Beispiel #1
0
 private void web_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
 {
     WXGZHArticle.LogUtil.Log("WebBrowserDocumentCompleted回调成功");
     web.Stop();
     System.Threading.Thread.Sleep(500);
     //微软官方回答 一个网页有多个Ifram元素就有可能触发多次此事件, 并且提到了
     // vb 和 C++ 的解决方案, C# 没有提及, 经本人尝试,发现下面的语句可以判断成功
     // 如果未完全加载 web.ReadyState = WebBrowserReadyState.Interactive
     master.HtmlString = web.Document.Body.InnerHtml;
     master.Success    = true;
     WXGZHArticle.LogUtil.Log("获取网页html成功");
     try
     {
         //Thread.CurrentThread.Abort();
         Application.Exit();
         WXGZHArticle.LogUtil.Log("线程终止成功");
     }
     catch (Exception ex)
     {
         WXGZHArticle.LogUtil.Log(Thread.CurrentThread.ManagedThreadId + "终止失败");
         WXGZHArticle.LogUtil.Log(ex.Message);
         WXGZHArticle.LogUtil.Log(ex.StackTrace);
         WXGZHArticle.LogUtil.Log(ex.InnerException.Message);
         WXGZHArticle.LogUtil.Log(ex.InnerException.StackTrace);
         WXGZHArticle.LogUtil.Log("异常打印结束");
     }
 }
Beispiel #2
0
 public void Stop()
 {
     browser.Stop();
     this.IsBusy = false;
     OnBusyStatusChange?.Invoke(this.IsBusy, new EventArgs());
     OnStopped?.Invoke(this, new EventArgs());
 }
Beispiel #3
0
 private void webBrowser1_StatusTextChanged(object sender, EventArgs e)
 {
     if (webBrowser != null)
     {
         if (webBrowser.StatusText.Contains("res:////"))
         {
             //  MessageBox.Show("resErr :StatusText=" + webBrowser.StatusText);
             if (!isNavigatErr)
             {
                 webBrowser.Stop();
                 endErr();
             }
         }
     }
 }
Beispiel #4
0
 static void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 {
     try
     {
         System.Threading.Thread.Sleep(500);
         if (_browserControl != null)
         {
             _browserControl.Stop();
             _browserControl.Dispose();
         }
     }
     catch (Exception ex)
     {
         MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
     }
 }
 public static String GetHtmlByWebBrowser(String url, DependencyObject dispatcher)
 {
     ManualResetEvent mre = new ManualResetEvent(false);
     StreamReader stream = null;
     dispatcher.Dispatcher.Invoke(new Action(() =>
     {
         WebBrowser wb = new WebBrowser();
         wb.Navigate(url);
         wb.Navigated +=new WebBrowserNavigatedEventHandler((Object sender,WebBrowserNavigatedEventArgs e)=>
         {
             wb.Stop();
             Encoding encoding = Encoding.GetEncoding(wb.Document.Encoding);
             stream = new StreamReader(wb.DocumentStream, encoding);
             wb.Dispose();
             mre.Set();
         });
     }));
     mre.WaitOne();
     return stream.ReadToEnd();
 }
Beispiel #6
0
 private void toolStripButton5_Click(object sender, EventArgs e)
 {
     wb.Stop();
 }
Beispiel #7
0
 public void StopLoading()
 {
     view.Stop();
 }
Beispiel #8
0
        /* D O  N A V  T O  P A G E */
        /*----------------------------------------------------------------------------
            %%Function: DoNavToPage
            %%Qualified: ArbWeb.ArbWebControl.DoNavToPage
            %%Contact: rlittle

        ----------------------------------------------------------------------------*/
        public bool DoNavToPage(WebBrowser wbc, string sUrl)
        {
            ReportNavState(String.Format("Entering FNavToPage({0})", sUrl));
            wbc.Stop();

            // m_wbc.Stop();
            WaitForBrowserReady();
            m_fNavDone = false;

            wbc.Navigate(sUrl);
            wbc.Visible = true;

            return FWaitForNavFinish();
        }
Beispiel #9
0
        internal static bool StopWebBrowser(WebBrowser webBrowser)
        {
            WebBrowserInfo info = null;
            if (webBrowser.Tag is WebBrowserInfo)
            {
                info = (WebBrowserInfo)webBrowser.Tag;
                if (info != null)
                {
                    if (info.Cleared == true)
                    {
                        webBrowser.Stop();
                        return true;
                    }
                    else
                    {
                        info.Cleared = true;
                        return false;
                    }
                }
            }

            return false;
        }
 /// <summary>
 /// Metodo que ejecuta el timer
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void runWorkerTimer(object sender, ElapsedEventArgs e)
 {
     webBrowser.Stop();
     timer1.Enabled = false;
     cargoPagina    = 2;
 }
Beispiel #11
0
 void StopButtonClick(object sender, System.EventArgs e)
 {
     webBrowser.Stop();
     StopDiscovery();
     addButton.Enabled = false;
 }