1. . C#.NET.
C# , . , , . , . . .NET Framework, , , . , , , , C#, , , , , .
. , , . .. , .
(- - thread, ) , . , , , , , , . : . 10-15 . , , , , , 10-15 , . .
, , ( ), . . .
.NET Framework : : .
(foreground) ( - background), , , , , .
, , , , . . , , , .
C#, , , System.Threading.
|
|
C#.NET.
, . 4 , .
, , , . .
, , Thread_Step_1. . :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Thread_Step_1
{
class Program
{
static void Main(string[] args)
{
}
}
}
System.Threading. using System.Threading using System.Text.
Main WriteString, , ( ) . _Data, .
:
static void WriteString(object _Data)
{
// :
// _Data string
// str_for_out
string str_for_out = (string) _Data;
// 1 ( )
for (int i = 0; i <= 1000; i++)
Console.Write(str_for_out);
}
Main. :
1. 4 , , WriteString.
2. .
3. , .
4. - , .
Main :
static void Main(string[] args) //
{
// 4 ,
Thread th_1 = new Thread(WriteString);
Thread th_2 = new Thread(WriteString);
Thread th_3 = new Thread(WriteString);
Thread th_4 = new Thread(WriteString);
//
th_1.Priority = ThreadPriority.Highest; //
th_2.Priority = ThreadPriority.BelowNormal; //
th_3.Priority = ThreadPriority.Normal; //
th_4.Priority = ThreadPriority.Lowest; //
// ,
th_1.Start("1");
th_2.Start("2");
th_3.Start("3");
th_4.Start("4");
Console.WriteLine(" ");
|
|
//
th_1.Join();
th_2.Join();
th_3.Join();
th_4.Join();
Console.ReadKey(); // ( ( )).
}
(F5). 1. , , , . Visual Studio ( ), , , , , .
1.
, , 4- , 1- , Highest . , 4- , , .
2. Visual C#
Visual Studio 2008
BackgroundWorker System.Threading ; System.Threading .
, , , . , , , . , , . , .
. . "Label". , , . , , . .
, , , . . , . |