如何从代码中杀死xbap实例 [英] How to kill xbap instance from code
问题描述
我创建了一个xbap应用程序,从该应用程序动态创建多个Presentation Host对象
我在关闭主xbap应用程序时关闭动态创建的Presentation主机对象,但IE成为空白。
如何通过每个标签杀死IE(xbap加载浏览器)的演示主机。
列表与LT; INT> ids = new 列表< int>(); // 包含演示主机进程ID
foreach ( var id in ids)
{
var pro = Process.GetProcessById(id);
pro.Kill();
}
提前致谢
我尝试了什么:
要关闭当前加载xbap的浏览器,我尝试了以下方式,但这将关闭所有IE标签
dynamic scriptObject = BrowserInteropHelper.HostScript;
scriptObject.Close();
要关闭当前加载xbap的浏览器,这将关闭所有IE选项卡
dynamic scriptObject = BrowserInteropHelper.HostScript;
scriptObject.Close();
使所有Internet Explorer进程在系统上运行
var iExplorerInstances = new ShellWindows();
var filteredData = iExplorerInstances.Cast< InternetExplorer>()。Where(iExplorer = > iExplorer.Name == Internet Explorer&& iExplorer.Visible).ToList();
通过
关闭每个IE标签var ieUrl = http://abc.com
foreach ( var fdata in filteredData.ToList())
{
if (fdata.LocationURL.Contains(ieUrl))
{
fdata.Quit();
break ;
}
}
使用以下代码,我们可以在关闭浏览器之前管理显示确认消息
fdata.Document.ShowMessage();
I created a xbap application, From that application dynamically create multiple Presentation Host objects
I closed dynamically created Presentation host object on closing main xbap appication , but IE become blank.
How can i kill Presentation host with IE(xbap loaded browser)by each tab.
List<int> ids=new List<int>();//contain Presentation Host process id
foreach (var id in ids)
{
var pro = Process.GetProcessById(id);
pro.Kill();
}
Thanks in advance
What I have tried:
To close current xbap loaded browser,i tried by below way, but this will close all IE tab
dynamic scriptObject = BrowserInteropHelper.HostScript;
scriptObject.Close();
To close current xbap loaded browser, this will close all IE tab
dynamic scriptObject = BrowserInteropHelper.HostScript; scriptObject.Close();
To get all Internet Explorer process running on System
var iExplorerInstances = new ShellWindows(); var filteredData = iExplorerInstances.Cast<InternetExplorer>().Where(iExplorer => iExplorer.Name == "Internet Explorer" && iExplorer.Visible).ToList();
To close each IE tab by
var ieUrl="http://abc.com" foreach (var fdata in filteredData.ToList()) { if (fdata.LocationURL.Contains(ieUrl)) { fdata.Quit(); break; } }
Using below code , We can manage show confirmation message before close the browser
fdata.Document.ShowMessage();
这篇关于如何从代码中杀死xbap实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!