Hour 18

   

1:

How is event handling handled internally for a native C++ application? (Hint: Remove the __gc keywords and the namespace declarations from this hour's lesson.)

A1:

Native C++ event handling uses a linked list that stores function pointers for each event handler. It also creates a special function that, when called, walks through the list and calls each of those functions.

2:

How is a delegate related to an event?

A2:

A delegate is another name for the event handler for that event. In other words, when a delegate is associated with an event, that delegate will be called when the event is fired.

3:

How many function pointers can a delegate contain and how do you find out how many a certain delegate can call?

A3:

A delegate can contain more than one pointer to an event handler when the CombineImpl function is declared in the delegate class. To find out how many functions the delegate is bound to, call the function GetInvocationList and access the Count property of that result.

4:

How would you go about implementing your own Invoke function within a delegate class?

A4:

Call the GetInvocationList member function and then walk through the array of delegates that was returned, calling each function to which each delegate is bound.


   
Top


Sams Teach Yourself Visual C++. NET in 24 Hours
Sams Teach Yourself Visual C++.NET in 24 Hours
ISBN: 0672323230
EAN: 2147483647
Year: 2002
Pages: 237

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net