如何建立在由code中一个实例的.NET程序的另一个实例? [英] How do I create another instance of a .NET program within one instance by code?
本文介绍了如何建立在由code中一个实例的.NET程序的另一个实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要能够在点击一个按钮创建一个程序的另一个品牌的新实例,同时保持现有的实例。
I need to be able to create another brand new instance of a program on a button click while keeping the existing instance.
this.ShowDialog(new Form1());
上面的语句将导致目前的形式是新形式的主人,我需要的第二个实例独立于现有的实例。
The above statement causes the current form to be the owner of the new form and I need the second instance to be independent of the existing instance.
谁能帮助我?
推荐答案
要在这里阐述的工兵的回答是一个简单的例子,你可以尝试一个表格和一个按钮:
To expound on Desolator's answer here is a simplistic example you can try a Form and a Button:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = Application.ExecutablePath;
p.Start();
}
}
这篇关于如何建立在由code中一个实例的.NET程序的另一个实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文