private void button1_Click( object sender, EventArgs e ) {
Timer timer = new Timer() {
Interval = 10000
};
timer.Tick += Timer_Tick;
timer.Start();
try {
using ( PrintDialog pdi = new PrintDialog() ) {
if ( pdi.ShowDialog( this ) == DialogResult.Cancel ) {
return;
}
MessageBox.Show( "Printing" );
}
} finally {
timer.Stop();
timer.Dispose();
}
}
private void Timer_Tick( object sender, EventArgs e ) {
SendKeys.Send( "{ESC}" );
}