
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
528
|
Chapter 9: Delegates, Events, and Anonymous Methods
Note that if the ObservableHashtables are used without registering them, no events
will be raised. Since no events are raised, the observer cannot do its job, and values
may be added to the unregistered subjects that are out of bounds for the application.
When using the observer design pattern in this fashion, keep in mind that fine-
grained events, such as the ones in this recipe, could possibly drag down perfor-
mance, so profile your code. If you have many subjects raising many events, your
application could fail to meet performance expectations. If this occurs, you need to
either minimize the number of actions that cause events to be raised or remove some
events.
See Also
See the “Event Keyword,” “EventHandler Delegate,” “EventArgs Class,” and “Han-
dling and Raising Events” topics in the MSDN documentation.
9.10 Using the Windows Keyboard Hook
Problem
You need to watch and respond to specific user keyboard input, and, based on the
input, you want to perform one or more actions. For example, pressing the Win-
dows key and the E key at the same time launches Windows Explorer. You would
like to add other Windows key combinations for your own applications. In addition,
observer.ApproveChange +=
new HashtableObserver.Approval(SeekApproval); ...