private void BgwConnectionTester_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker bgw = (BackgroundWorker)sender; bool dbTestResult = DbManager.TestConnection(e.Argument.ToString()); e.Result = dbTestResult; }
private void BgwStartupCheck_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker bgw = (BackgroundWorker)sender; System.Threading.Thread.Sleep(1000); // show the splash so the user doest panic over a flashing form. // Test db connection: UpdateStatusLabel("Testing database connection..."); bool dbTestResult = DbManager.TestConnection(); if (!dbTestResult) { e.Result = -1; UpdateStatusLabel("Database connection failed."); } UpdateStatusLabel("All good in the hood." + ((bool)e.Argument ? " Showing film." : "")); // If we are requested to show the entire startup sequence. if ((bool)e.Argument) { System.Threading.Thread.Sleep(22500); pictureBox1.Image = Resources.SplashSquence; } else { System.Threading.Thread.Sleep(200); } e.Result = 0; }