Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. LINQ;
Using system. text;
Using system. Windows. forms;
Using system. Threading;
Namespace windowsformsapplication2
{
Public partial class form2: Form
{
// Test Ts = new test (LBL );
Public form2 ()
{
Initializecomponent ();
}
Private void button#click (Object sender, eventargs E)
{
Testprint ();
}
Private string message = "";
Private thread;
Private datetime D;
Private int pageindex = 1;
// Public test (Label L)
//{
//}
Public void testprint ()
{
Thread = new thread (testprintstart );
Thread. Start ();
}
Public void testprintstart ()
{
D = datetime. now;
Message + = "new printing start \ r \ n ";
Thread. Join (1, 3000 );
Testpagestart ();
}
Public void testpagestart ()
{
Message + = string. Format ("Wait {0} seconds \ r \ n", (timespan) (datetime. Now-D). totalseconds );
Testpageend ();
}
Public void testpageend ()
{
Message + = string. Format ("printing page {0} \ r \ n", pageindex );
If (pageindex = 5)
{
Testprintend ();
}
Else
{
Pageindex ++;
D = datetime. now;
Thread. Join (1, 3000 );
Testpagestart ();
}
}
Public void testprintend ()
{
Message + = string. Format ("printing end ");
LBL. Text = message. tostring ();
}
}
}