private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { errorx.Invoke((MethodInvoker) delegate { errorx.Visible = false; lbl_message.ForeColor = Color.Black; }); int sleeping = 200; System.Threading.Thread.Sleep(sleeping); lbl_message.Invoke((MethodInvoker) delegate { lbl_message.Text = "Initializeing database connection............"; progressBar1.Value = 20; }); if (SecurityRepository.CheckDBConnection()) { System.Threading.Thread.Sleep(sleeping + 800); lbl_message.Invoke((MethodInvoker) delegate { lbl_message.Text = "Initializeing System Variables ............."; progressBar1.Value = 40; }); System.Threading.Thread.Sleep(sleeping + 400); lbl_message.Invoke((MethodInvoker) delegate { lbl_message.Text = "Initializeing User Permission settings ............."; progressBar1.Value = 50; }); System.Threading.Thread.Sleep(sleeping + 400); lbl_message.Invoke((MethodInvoker) delegate { lbl_message.Text = "System Ready ............."; progressBar1.Value = 100; mainpanel.Enabled = true; }); System.Threading.Thread.Sleep(sleeping + 400); lbl_message.Invoke((MethodInvoker) delegate { progressBar1.Visible = false; lbl_message.Visible = false; }); } else { lbl_message.Invoke((MethodInvoker) delegate { errorx.Visible = true; lbl_message.Text = "Database Connection Error ............."; lbl_message.ForeColor = Color.Red; }); return; } }