Utini wrote:is this an example of the Observer pattern as implemented in C#?
Yes, it is. A few points that may be worth mentioning:
- Observers can attach themselves by chaining a listening delegate to
BarcodeScanner or implementing an
IBarcodeScannerListener interface and attaching themselves by calling an
BarcodeScanner.addListener() method. Delegates offer more flexibility in that the observer can supply any (valid) listening method at run time. I find the latter method meets my needs as it clearly indicates that a class is an observer of
- As with any listener, you need to be careful of cross thread calls (if
BarcodeScanner is running in a separate thread). See the doc on
EndInvoke() for more information.
- Because listeners will typically block execution of
BarcodeScanner, you should ensure that the listener method is lightweight.
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips