I have a roster program.
When the print button is pushed a form appears that asks for the users userid.
When the id is entered and the go button is pushed the form writes a variable in the settings.settings file that says whether the user has privellages to print. The form then closes.
The roster then prints if the variable is 1 otherwise nothing happens.
Currently I have the roster sleeping for 5 seconds using
System.Thread.Sleep(5000);
How can I have it wait for the other form to close then proceed with the printing instead of having it sleep for 5seconds as this causes issues if the user takes longer than 5seconds.
private void button2_Click(object sender, EventArgs e) { var t = new Thread(() => Application.Run(new UserPrinter())); t.Start(); Thread.Sleep(10000); if(Properties.Settings.Default.CanPrint == 1) { Thread.Sleep(10000); CaptureScreen(); printDocument1.DefaultPageSettings.Landscape = true; printDocument1.Print(); } else { MessageBox.Show("n/a"); } }
Sorry about the spelling.
Matt