.


:




:

































 

 

 

 


,




1. frmCalculations. .

public delegate void FHandler(double Value, double Calculations);

public delegate void A2Handler(int Value, double Calculations);

public delegate void LDHandler(double Calculations, int Count);

Invoke BeginInvoke . , BeginInvoke .

2. .

public void FactHandler(double Value, double Calculations)

{

}

public void Fact1Handler(double Value, double Calculations)

{

}

public void Add2Handler(int Value, double Calculations)

{

}

public void LDoneHandler(double Calculations, int Count)

{

}

3. FactorialHandler FactHandler.

4. FactorialMinusHandler, Fact1Handler, AddTwoHandler, Add2Handler, LoopDoneHandler LDoneHandler.

FactorialHandler, Factorial1Handler, AddTwoHandler LoopDoneHandler . .

5. BeginInvoke. BeginInvoke (this), .

.

protected void FactorialHandler(double Value, double Calculations)

{

// BeginInvoke causes asynchronous execution to begin at the address

// specified by the delegate. Simply put, it transfers execution of

// this method back to the main thread. Any parameters required by

// the method contained at the delegate are wrapped in an object and

// passed.

this.BeginInvoke(new FHandler(FactHandler), new Object[]

{Value, Calculations});

}

protected void FactorialMinusHandler(double Value, double Calculations)

{

this.BeginInvoke(new FHandler(Fact1Handler), new Object []

{Value, Calculations});

}

 

protected void AddTwoHandler(int Value, double Calculations)

{

this.BeginInvoke(new A2Handler(Add2Handler), new Object[]

{Value, Calculations});

}

 

protected void LoopDoneHandler(double Calculations, int Count)

{

this.BeginInvoke(new LDHandler(LDoneHandler), new Object[]

{Calculations, Count});

}

, . , . , , .

6. .

7. , .

a. 10000000 .

" ". . , .

b. , . . . . , , 10 000 000, . .

, . , .

. , Calculator:

varTotalCalculations += 1;

varTotalAsOfNow = varTotalCalculations;

varTotalCalculations varTotalAsOfNow. frmCalculations . , . , . , . varTotalCalculations. , varTotalAsOfNow, . , . Visual C# lock, . , . lock :

lock(AnObject)

{

// Insert code that affects the object.

// Insert more code that affects the object.

// Insert more code that affects the object.

// Release the lock.

}

lock, , . AnObject. lock , , . , . , , . } .





:


: 2016-09-03; !; : 392 |


:

:

, , .
==> ...

1800 - | 1479 -


© 2015-2024 lektsii.org - -

: 0.008 .