【发布时间】:2017-02-27 01:51:57
【问题描述】:
我有一个 Web 浏览器控件,它添加到用户控件中,并在选择电子邮件时自动导航到特定 URL(比如说https://www.google.com)。在导航过程中,当单击电子邮件时,它会减慢 Outlook 的实际性能,并且 Outlook 会等待页面加载。有没有办法在点击各种电子邮件时在后台执行此导航而不实际影响 Outlook 的性能?
谢谢。
更新:
插件启动代码:
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 代码(电子邮件选择更改):
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
文档完成代码:
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
【问题讨论】:
-
我认为 Web 浏览器控件执行其加载任务时不会减慢 UI。你有没有通过任务管理器查看资源使用情况?
-
好吧,我认为他们应该这样做,但是,在我的情况下,正在进行大量加载,并且加载 Web 浏览器内容需要很长时间。当我将当前电子邮件地址传递给 Web 浏览器控件时,网页会根据当前电子邮件地址进行更改。
-
如果您的页面很重,浏览器可能会挂起是正常的(即使您使用现实生活中的浏览器也会发生这种情况)。如果浏览器和outlook在同一个进程,那会让大家变慢。
-
有没有办法让这个 Web 浏览器控件在不同的线程上运行或其他什么东西,这样它一般不会影响 Outlook 的性能?
-
问题中缺少帮助您的细节。如前所述,加载 Web 浏览器需要在单独的线程上。您没有发布您尝试过的任何代码,因此如果我们看不到您在做什么,我们将无法帮助您...如果您想要一个好的答案,请更新您的帖子。
标签: vb.net email outlook webbrowser-control loading