炫意html5
最早CSS3和HTML5移动技术网站之一

C# WinForm 进度条。会动!

这样写2秒后不会关闭

        private void button1_Click(object sender, EventArgs e)
{
Form7 form7 = new Form7();
form7.ShowDialog();
System.Threading.Thread.Sleep(2000);
form7.Close();
}

但是,这样写进度条不会动……

        private void button1_Click(object sender, EventArgs e)
{
Form7 form7 = new Form7();
form7.Show();
System.Threading.Thread.Sleep(2000);
form7.Close();
}

这是Form7

using System.Windows.Forms;
namespace test
{
public partial class Form7 : Form
{
public Form7()
{
InitializeComponent();
}
}
}

回答

显示
TProcess = Task.Factory.StartNew(() =>
{
form7= new Form7();
form7.ShowDialog();
});
关闭
this.Invoke(new Action(() =>
{
if (form7!= null)
{
form7.Close();
form7.Dispose();
form7= null;
}
}));

炫意HTML5 » C# WinForm 进度条。会动!

Java基础教程Android基础教程