Web browser control loading Outlook unusable VB.Net

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 16:25:38

问题


I have a web browser control that is added to a user control and is automatically made to navigate to a specific URL when an email is selected (lets say https://www.google.com). Whilst the navigation is going on, when clicking through emails, it slows down the actual performance of Outlook and outlook waits for the page to load. Is there a way I could carry out this navigation in the background without actually affecting the performance of Outlook when clicking through various emails?

Thanks.

Update:

AddIn Startup Code:

 Private Sub ThisAddIn_Startup() Handles Me.Startup

        myUserControl1 = New OutlookTaskPane
        myUserControl1.TabStop = True
        Dim width As Integer = myUserControl1.Width
        myCustomTaskPane = Me.CustomTaskPanes.Add(myUserControl1, "Title")
        myCustomTaskPane.Width = width
        myCustomTaskPane.Visible = True
        myCustomTaskPane.DockPositionRestrict = Microsoft.Office.Core.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange

        currentExplorer = Me.Application.Explorers.Application.ActiveExplorer
        AddHandler currentExplorer.SelectionChange, AddressOf myOutlookExplorer_SelectionChange
    End Sub

SelectionChange Code (On Email selection change):

Private Sub myOutlookExplorer_SelectionChange() Handles currentExplorer.SelectionChange
        Dim RandNum As Integer = myUserControl1.GetRandomNumber(1, 100)
        ' Grid Loading Link
        myUserControl1.WebBrowser1.Navigate("https://www.google.com" & "?" & RandNum, Nothing, Nothing, "User-Agent:  Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko")
    End Sub

Document Completed Code:

Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        ' If the document is not completely ready, then don't perform the events below
        If Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
            Return
        End If
.... // lots of field setting/DOM manipulation after the DOM is loaded
End Sub

回答1:


I suppose you are using System.Windows.Forms.WebBrowser.

There is a Stop() method you could try to call before you request a new Navigate(String).



来源:https://stackoverflow.com/questions/40097237/web-browser-control-loading-outlook-unusable-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!