111,126
社区成员
发帖
与我相关
我的任务
分享
private void init()
{
timer.start();
Form f = new Form();
}
public partial class LoginLoading : Form
{
public static MainForm mainForm;
public static bool isLoad = true;
private Thread progressBarThread;
private int progressBarValue = 1;
private bool flag;
public LoginLoading()
{
InitializeComponent();
}
private void LoginLoading_Load(object sender, EventArgs e)
{
progressBarThread = new Thread(RunProgressBar);
progressBarThread.Start();
this.backgroundWorker.RunWorkerAsync();
}
private void RunProgressBar()
{
flag = true;
while (flag)
{
this.progressBar.Value = progressBarValue;
progressBarValue++;
Thread.Sleep(200);
}
}
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
if (mainForm == null)
{
mainForm = new MainForm();
}
flag = false;
this.progressBar.Value = 100;
Thread.Sleep(100);
}
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.Hide();
Thread.Sleep(500);
mainForm.Show();
}
}
public partial class MainForm : Form
{
public MainForm()
{
MainForm_Load(null,null);
}
public void MainForm_Load(object sender, EventArgs e)
{
if (LoginLoading.isLoad)
{
LoginLoading.isLoad = false;
Thread thread = new Thread(new ThreadStart(initControl));
thread.IsBackground = true;
thread.Start();
}
}
public void initControl()
{
if (control == null)
{
pnlMain.Invoke((EventHandler)(delegate
{
control = new Control();
}));
}
}
}