I designed an easy solution. I have not used Asynhcronous model. If it is needed you can use BackgroundWorker class.
My code is below.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnOpen_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
}
}
Form2.cs
public partial class Form2 : Form
{
Timer tmr;
ProgressBar p;
frmSplash f;
public Form2()
{
InitializeComponent();
tmr = new Timer();
tmr.Interval = 1000;
tmr.Tick += new EventHandler(tmr_Tick);
tmr.Start();
p = new ProgressBar();
p.Height = 30;
p.Width = 320;
f = new frmSplash(p);
f.Show();
}
void tmr_Tick(object sender, EventArgs e)
{
p.Value += 20;
if (p.Value == 100)
{
tmr.Stop();
Application.DoEvents();
f.Hide();
this.Show();
}
}
}
And I added a WinForm named frmSplash and put a flowLayoutPanel on it. Code is below.
public partial class frmSplash : Form
{
public frmSplash(ProgressBar prg)
{
InitializeComponent();
flowLayoutPanel1.Controls.Add(prg);
}
}
Run Form1 and click button. First splash form will be opened after progressbar is filled it will be hide and Form2 will be displayed.
Regards,