如何在所选选项卡中关闭并终止Web浏览器进程 [英] how to close and kill the web browser process in the selected tab

查看:125
本文介绍了如何在所选选项卡中关闭并终止Web浏览器进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标签式网页浏览器,所以每次关闭标签时标签都会关闭但过程仍在运行,例如我的一个标签页面上有一个YouTube页面已打开,所以如果我关闭该标签页面,视频仍在运行你甚至可以听到声音,以便如何关闭和杀死所选标签中的网络浏览器进程。

,这里是代码

 < span class =code-keyword>公共  Sub  removetab()
如果 TabControl1.TabPages.Count<> 1 然后
Dim 浏览器 As webbrowser = Me .TabControl1.SelectedTab.Tag
browser。停止()
TabControl1.TabPages.Remove(TabControl1.SelectedTab)
url.Text = TabControl1.SelectedTab.Text
结束 如果
结束 Sub

解决方案

请参阅我对该问题的评论。



致电 webbrowser.Dispose()。永远不要忘记为实现此接口的每种类型的每个实例调用 System.IDisposable.Dispose()



你不应该问这些关于你没有精确命名的控件的模糊问题。两种类型的简单名称 TabControl WebBrowser 都不明确。我甚至需要告诉你它们可以出现在哪里吗?要么提到完整的类型名称,要么显示你的using / imports指令,或者指定你正在使用的UI库。



-SA

i have a tabbed web browser so every time i close a tab the tab is closed but the process is still running for example one of my tabs there is a YouTube page opened so if i close that tab the video is still running you even can hear the sounds so how to close and kill the web browser process in the selected tab.
and here is the code

Public Sub removetab()
    If TabControl1.TabPages.Count <> 1 Then
        Dim browser As webbrowser = Me.TabControl1.SelectedTab.Tag
        browser.Stop()
        TabControl1.TabPages.Remove(TabControl1.SelectedTab)
        url.Text = TabControl1.SelectedTab.Text
    End If
End Sub

解决方案

Please see my comment to the question.

Call webbrowser.Dispose(). Never forget to call System.IDisposable.Dispose() for each and every instance of every type implementing this interface.

You should not ask such ambiguous questions about controls you failed to name precisely. Both type simple names TabControl and WebBrowser are ambiguous. Do I even need to tell you where they can appear? Either mention full type names, or show your using/imports directives, or specify UI library you are using.

—SA


这篇关于如何在所选选项卡中关闭并终止Web浏览器进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆