.


:




:

































 

 

 

 


Action. , Action .




Public delegate void Action()

, , Invoke () , , . actions params, . Action, .

Invoke () , . , , ( ) Wait (). Wait () . , , , , . , , , .

Invoke () . MyMeth () MyMeth2 () Invoke (). .

// Parallel.Invoke() .

Using System;

Using System.Threading;

Using System.threading.Tasks;

class DemoParallel {

// , , static void MyMeth() {

Console.WriteLine("MyMeth ");

for (int count = 0; count < 5; count++) {

Thread.Sleep(500);

Console.WriteLine(" MyMeth " + count);

}

Console.WriteLine("MyMeth ");

}

// , , static void MyMeth2() {

Console.WriteLine("MyMeth2 ");

for(int count = 0; count < 5; count++) {

Thread.Sleep(500);

Console.WriteLine(" MyMeth2, " + count);

}

Console.WriteLine("MyMeth2 ");

}

static void Main() {

Console.WriteLine(" .");

// .

Parallel.Invoke(MyMeth, MyMeth2);

Console.WriteLine(" .");

}

}

.

.

MyMeth() MyMeth2() MyMeth() 0 MyMeth2() 0 MyMeth() 1 MyMeth2() 1 MyMeth() 2 MyMeth2() 2 MyMeth() 3

MyMeth2() 3 MyMethO 4 MyMeth()

MyMeth2() 4 MyMeth2() .

: Main () , Invoke (). , Main (), MyMeth () MyMeth2 (), . Invoke () , , .

, Invoke () . , Invoke () -.

// Parallel.Invoke() . // -.

Using System;

Using System.Threading;





:


: 2016-12-03; !; : 372 |


:

:

.
==> ...

1416 - | 1387 -


© 2015-2024 lektsii.org - -

: 0.012 .