after startup, a timer is automatically activated and this is triggered when the timer time is reached. close
Public partial class form1: Form
{< br> timer my timer = new timer ();
Public form1 ()
{< br> initializecomponent ();
}
Private void form1_load (Object sender, eventargs E)
{
My Timer. interval = 10000; // set the time to 10 seconds
My Timer. Tick + = new eventhandler (my timer _ tick );
My Timer. Start (); // This timer is automatically started when the form is loaded
}
// Timer timing event
Void my timer _ tick (Object sender, eventargs E)
{
This. Close (); // when the time is up, the form close event will be triggered.
}
}
Stopwatch can be used for computingProgramModule running time ..
using system. diagnostics;
stopwatch TM = new stopwatch ();
TM. Start ();
A module...
TM. Stop ();
MessageBox. Show (TM. elapsed. milliseconds. tostring (), "training done");