winform如何控制子窗体最小化后不影响操作主窗体打开子窗体
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace FormA
{
public partial class FormA : Form
{
public FormA()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Thread thread = new Thread(threadPro);
thread.Start();
}
private void threadPro()
{
MethodInvoker methodInvoker = new MethodInvoker(ShowFormB);
BeginInvoke(methodInvoker);
}
private void ShowFormB()
{
FormB frmB = new FormB();
frmB.Show();
}
}
}
A主窗体,B子窗体
private delegate dialogresult showB();
private void show(object obj)
{
Form f=(Form)obj;
showB=f.showdialog();
f.invok(showB);
}
在弹出窗体事件中
new thread(show).start(new B());
这样,B窗体将和A窗体相互独立互不影响