As I am virtually incapable of doing anything the same way twice, I had to go out and find another way to deal with blocking operations (blocking as in network blocking), and came across Asynchronous Method Invocation at the Code Project. Perfect. The author, Mike Peretz, does an excellent job of explaining Begin/EndInvoke, delegates, catching errors, and the Command Pattern. Even if you’re fine with asynchronous operations, invocations, and delegates, it’s a good read.
The reason I wanted a new way is because I’ve been adding some new features to my Super Simple Photo Resizer: cropping and uploading photos to TwitPic and then tweeting them on Twitter. I’ve been having a lot of fun with it, and you can check out some of my testing pictures of a cute possum here.
Photo Resizer is very quick in resizing and cropping photos, so there really isn’t any need to bother with dealing with saving asynchronously. However, the new upload features and tweeting features take more than the blink of an eye, and they require asynchronicity to maintain a nice, fluid user experience. I had a bit of fun with it too. In a “cancel” warning screen, instead of a regular, boring yellow triangle and exclamation mark warning/caution symbol, I used the “Oh no!” smiley you can see in the upper right here. Again, that was one of the graphics I purchased at Vector Stock.
I opted to run with Begin/EndInvoke and delegate callbacks this time around. It works well, and the UI remains smooth and easy to use.
However, the Command Pattern really looked a lot better. But there was just so much good stuff in the article that I decided to just put it to memory and save the Command Pattern for another day. So next time, rather than look around to figure out a new way to do the same old thing, I’ll already have something new to try.