.


:




:

































 

 

 

 





() .

, .

, .. . , , . , .

#, . lock.

lock :

lock(object)

{

// , .

}

object .

lock , , , , . lock , . , CA , :

static void Min(int a, int b)

{

:

},

:

lock(typeof(CA)) CA.Min(x,y);

Windows. . X , Y 10*j, j . 45 . , . 200 200 , . . , , .

3:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Threading;

namespace Balls

{

public partial class Form1: Form

{

class Ball

{

int x, y; //

int dx, dy; // -

int w, h; //

public bool live; //

public delegate void DlTp();// ()

//

// Invalidate()

public DlTp dl;

public Thread thr; //

//

void FnThr()

{

while (live)

{ //

if (x < 0 || x > 200) dx = -dx;

if (y < 0 || y > 200) dy = -dy;

//

x += dx;

y += dy;

Thread.Sleep(100);//

dl(); // Invalidate()

}

w = h = 0; //

dl(); // Invalidate()

}

//

public void DrawBall(Graphics dc)

{

dc.DrawEllipse(Pens.Magenta, x, y, w, h);

}

//

public Ball(int xn, int yn, int wn, int hn, int dxn, int dyn)

{

x = xn; y = yn; w = wn; h = hn; dx = dxn; dy = dyn;//

thr = new Thread(new ThreadStart(FnThr)); //

live = true; //

thr.Start(); //

}

}

Ball[] bl = new Ball[10];// Ball

public Form1()

{

InitializeComponent();

for (int j = 0; j < bl.Length; j++)

{

//

bl[j] = new Ball(j, j * 10, 10, 10, j + 1, j + 1);

//

bl[j].dl += new Ball.DlTp(Invalidate);

}

}

private void Form1_Paint(object sender, PaintEventArgs e)

{

for (int j = 0; j < bl.Length; j++)

{

bl[j].DrawBall(e.Graphics);//

}

 

}

private void button1_Click(object sender, EventArgs e)

{

for (int j = 0; j < bl.Length; j++)

{

bl[j].live = false;//

}

}

 

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

{

for (int j = 0; j < bl.Length; j++)

{

bl[j].live = false;//

}

}

}

}

. .


 

:

1. , ?

2. ?

3. ?

4. ?

5. ?

6. ?

7. ?

8. ?

9. ?

10. ?

11. ?

12. ?

13. ?

 

:

1. 3 TextBox . , TextBox , .

2. 3 TextBox . , TextBox , .

3. 3 TextBox . , TextBox , .

4. 3 . , , . .

5. 3 . . . .

6. . . . , . () .

7. . . , . .

8. . . , . , 1000 , . .

9. Windows . . . , .

10. Windows . , . .. , .

1. 4

. 4

2. 14

, . 14

.. 16

. 18

.. 20

3. 26

, , . 26

. 28

. 30

. 31

4. 38

. 38

. 42

5. 49

Windows − . 49

6. 57

. 57

Size. 58

Point 58

Rectangle. 60

. 61

. 63

. 65

. 68

. 69

7. 74

.. 74

8. 87

. 87

. 87

. 92

. 95

 

 





:


: 2016-11-02; !; : 569 |


:

:

,
==> ...

1344 - | 1310 -


© 2015-2024 lektsii.org - -

: 0.021 .