In preparation for doing an Overview of Tablet PC Development presentation at the GUVSM.NET user group in Montreal earlier this week, I was rewriting all of my demos from scratch in Visual Studio 2005. From scratch because I haven't played with many of these features in a while and this was the best way to get my head wrapped around them again. In VS2005 because all of my tablet code was in VS2003 and my demo machine only has VS2005 on it now. I was looking forward to confirming that everything else was okay.
(Note that there is an update to the Microsoft.Ink.DLL that fixes some of the collisions between that API and the CLR 2.0. You can get it here. Currently it is not redistributable which means that you will have to have your users do the update to their computer themselves.)
I was happily going through the demos and had made it to the handwriting recognition section. The demo that I had used previously, which I was duplicating, displayed the results of the recognition in a TextBox on the same form where the inkable control lives. You may or may not realize (but you should!) that the TabletPC API is a COM API with a managed wrapper. The reco process is happening on a different thread. But this was not something I had paid attention to earlier (my bad) and it had never posed a problem. Yet in VS2005, I was not getting anything back. When I tried to debug, my app would hang when I tried to write to the text box. It took me a few minutes of head scratching to realize that the reco must, indeed, be happening on a separate thread and I couldn't pass the results back to the main UI thread. A re-think and re-write was necessary (thanks to some help from the aptly named, Josh Einstein, in the TabletPC Dev newsgroup.)
But the interesting thing here was that VS2003 did not have problems with the threading. The thing about threading off of the UI thread is that sometimes it will work, and sometimes it won't. (A good reason to handle it properly.)
I believe something changed in VS2005 which is much more sensitive, enforcing proper usage of threading. However, it was a hard way for me to find out that this is what was needed to fix the problem. I happen to know about UI threading and it was the first thing I thought of. What about the poor programmer who is not aware? More digging will be required on my part...