February 2007 - Posts

Anonymous Delegate Hell
15 February 07 10:56 AM | adrian | with no comments

Be careful when you're using anonymous delegate to handle external events. Anonymous delegate event handler are not unsubscribable... That means once you define it, it sticks around, even after the original object is destroyed. Take a look at the attached program.

The event is published from a static class Publisher. Client would call RaiseEvent() method to initiate the event.

Subscriber to the event are three classes, SubscriberA (using anonymous delegates), SubscriberANonAnonymous (using standard event handling delegate), and SubscriberANonAnonymousWithIDisposable (using standard event handling delegate plus IDisposable implementation to be used with using statement for explicit destruction). Each class will write a line to the console. The expected result was no line written, since disposed objects shouldn't handle events.

The fact: only SubscriberANonAnonymousWithIDisposable that does not write a line.

This problem does not happen when you use anonymous delegate to handle internal events, since the publisher most likely be gone in the process of destruction. An example of this would be handling of Button.Click event inside a Windows Form.

P.S.: To use the attached file, first create an empty Console Application Project, then copy paste the content of the file to the Program.cs.

Share this post: | | | |
Filed under:
5 Things You (May) Don't Know About Me
15 February 07 09:12 AM | adrian | with no comments
  1. I was introduced to a device called computer at the age of 3. Learned how to use Internet at the age of 10. Learned how to code at the age of 13. Learned design patterns at the age of 21. So far, it's earlier than most people.
  2. Corollary to 1 is that I have never learned anything deep enough to master it. You can ask me about anything basic and asnwer it, but not the details.
  3. I had a computer without hard drive but have a CD-ROM drive. I've known the concept of LiveCD since then. The CD runs DOS + QBasic + every other tools I needed.
  4. I had a computer with very limited HD, big enough to store JUST the OS, and used Notepad+HTML+IE to do word processing.
  5. Like Dondy, I've used C# (almost) exclusively, and have no plan on learning ASP.NET. Desktop apps all the way...
Share this post: | | | |
Show Wow! to the Public Part 2
11 February 07 12:11 AM | adrian | with no comments
Well, CS doesn't seem to be able to add multiple attachment per post, so here's the background file for the standard screen.
Share this post: | | | |
Show Wow! to the Public
11 February 07 12:00 AM | adrian | with no comments

It's never wrong to start showing what Windows Vista can do, especially the "wow" factor to the public. How?

Well, since Internet hotspots are flourishing in public places (like food courts and niche stores), we can use our own laptop to show off what can be done. For example, prefer using Flip 3D over standard Alt+Tab, or even simpler, use the cool attached wallpaper. It's easy to look (even Macs would love it), a Vista orb plus a word "Wow!" on the right. The VistaOrb.jpg is 1280x800 (for widescreens), and the VistaOrb2.jpg is 1024x768 (for standard screens).

Share this post: | | | |
Core 2 Duo Laptops
04 February 07 12:42 AM | adrian | with no comments

I'm in the market for Core 2 Duo laptops for both home (a.k.a. side jobs) and work. I'm looking for mid-market and portable laptops. Mid-market means the price is under US$2.000, while portable means screen size is 13". There are several choices available (actually, seven of them) as a result of my (maybe) exhaustive research online and offline. From all seven, I've narrowed them down to two recommended buys.

They are Sony Vaio VGN-C13G and Apple MacBook. (Apple, ha! - We'll talk about it later.) Here's a quick head-to-head comparison between them:

Product

Sony Vaio VGN-C13G

MacBook

Processor

Intel Core 2 Duo T5500

Intel Core 2 Duo T7200

Memory

512Mb (2Gb)

1Gb (2Gb)

L/W/H

329.6/235.6/36.7 mm

325/227/27.5 mm

OS

Windows XP Home

Mac OS X

HD

80Gb

80Gb

Weight

2.3kg

2.36kg

Screen

13.3 WXGA (1280x800)

13.3 WXGA

Price

US$1.510

US$1.306

A quick glance would heavily weighed in to Apple. I do, too. There's just one mistake there, it's an Apple. Three years ago, it won't even run Windows (at all), but since they're moving to Intel, things have drastically change.

And here's my (rather lengthy) review for those models...

  1. VGN-C13G
    At first, I was browsing through the US SonyStyle.com and found out about VGN-C190, the customizable, (very) colorful laptop from Sony. I've located a store selling one of the pre-made (non custom) C190, and they're selling for extremely marked-up price, ~1399 at SonyStyle to ~1899 at local store. Moreover, when I googled the store name, one of the result is a Reader's Letter from my local newspaper stating that the store didn't give out good after-sales service. I met with Narenda, and he told me the same story happened with our friend with his Vaio. Those were instant turn-offs. Fortunately, another store, listed as Authorized Seller by Sony, selling a fresh C13G. The specs are lower than C190, but this one has better support. You'll need to cough in extra US$215 for 2Gb of RAM.
    The Vaio C-series is a budget notebook line. It's Sony's low end when compared to other US$2.000+ Vaio. Comparing to other options, US$1.510 is a very good price. 2Gb upgrade raised the price to US$1.725, still quite reasonable for a Vaio. I've seen the model, it's nicely built, but comes with several quirks as well. Nothing major though. The size is quite bulky for a 13", but it's still comfortable to bring along.
  2. MacBook
    It's not the big and powerful 17" MacBookPro. I won't need half of the spec anyway. Plus, it's kinda idiot to bring around 17" notebook. The screen size and the total dimension are perfect, the spec and price are perfect, the looks, well you can't imperfect an Apple, but the biggest turn-off comes from the maker itself. Fortunately, more and more people tested that MacBook is fully compatible with Windows Vista (although with two "bugs", the Apple logo does not lit, and no Windows key on the keyboard). I'm sure this is something easy to hack. Another catch is the overpriced upgrades; Adding 1Gb of memory costs US$ 175 (compared to standard 1.5Gb upgrade of US$ 200), maybe I keep the old memories, too. Another upgrade that costs a lot is the warranty. Apple does not give out free standard one year warranty, they give out 90 days, and requires you to pay another US$ 200-something for one year warranty. Counting all those, this unit priced almost US$1.700.

Currently I'm setting my heart to the Vaio, but things might change if Apple can win me with their silly ads. I'll take a look at how good these Macintels run Windows Vista (after yesterday's general launch).

And if you're not interested in both models, I have provided a short but quite useful review for the other five:

  1. BenQ Joybook S31W
    I got the recommendation from CNET Asia. At US$1.389, the price was ground low for a laptop with this kind of specification. If you're looking for a new brand of laptop with cheap price, this is the way to go. Online reviews are scarce on this product. Bhinneka.com was seen selling this laptop. The problem is, BenQ have discontinued this product, so no more update will be available.
  2. IBM Thinkpad X60
    While S31W is at the low end of the budget, X60 is at the high end of the budget (US$1.679). This laptop boasts a tiny and thin case, 2cm thick. While it lasts very long (almost 8 hours of battery), this laptop skips optical drive (yeah, no CD drive at all). If you're constantly on the field, this could be a good choice (since it runs almost indefinitely).
  3. Lenovo Y300 - while it has good spec, prices are higher than average (US$1.729). Pretty standard IBM brand spec.
  4. HP Compaq B1919 - I was offered this product at Gramedia's IT Talk. It's the only HP they have with small screen (12"). The problem lies in both performance and battery life. Not worth buying.
  5. Acer Aspire 5594WXMi - Here's the standard, it has standard spec, standard price, standard quality, standard performance. If you're looking for a just notebook, this might be a good choice. It's 14", but total dimension is small for it's class.
Share this post: | | | |