Monday, November 26, 2007

The Missing Stopwatch and the Missing Milliseconds


While I've benefited tremendously from having my T-Mobile Wing, one of the things it's missing is a convenient stopwatch feature. My old cell phone provided a nice stopwatch, but there's nothing like this on the Wing. Even my Garmin GPS has a stopwatch feature, so I figure my cell phone should get one too.

This seems like a simple enough project and an excellent opportunity to jump into writing a C# project on the .NET Compact Framework. Well, the first thing I found out was that the DateTime object's Milliseconds property is always zero on a T-Mobile Wing. Some quick web searching revealed that this isn't a Wing peculiarity, but a lot of Windows CE devices don't provide millisecond resolution for calls to GetLocalTime() (which is ultimately beneath .NET's DateTime class).

A nice summary of alternatives can be found here. The simplest solution is to use System.Environment.TickCount to simply get the number of milliseconds that have passed since the operating system started. The only caveat is that the TickCount is suspended when the system goes into suspend mode. So if your device suspends, your stopwatch will stop ticking. However, for my needs this is sufficient for the time being. I'll look at workarounds in the future if I should need one.

Mobile Stopwatch can be found in the Mobile Tools download from this blog.

Switching to Windows Mobile

About six months ago I decided my Virgin Mobile prepaid cell phone was beginning to cost enough each month that I should look at a fixed price alternative. With the upgrade I was also hoping to add some new features to my phone.

I wanted to sync contacts and appointments with Outlook, so some kind of Palm/Blackberry/Windows Mobile device was worth investigating. Since I have a background developing software for Windows desktop operating systems, I figured with a Windows Mobile device and Microsoft Visual Studio I could learn a new development environment.

After some web searching I found I could get a pretty nice Windows Mobile 6 Professional device from T-Mobile for $99 (current offers can be found here) and my prepaid plan was history. I'll be blogging here about my experiences with Windows Mobile from both a user and developer perspective.