Windows Mobile User/Developer Holiday Gathering: December 16, 2009#
Post By Don Sorcinelli

‘Tis the season! In place of our normal Boston/New England Windows Mobile User and Developer Group meeting, we will be having a casual holiday get-together. We will be meeting at the Bison County BBQ and Grille, located at 275 Moody Street in Waltham, MA.

Map picture

We will plan on being there starting at 6:00 PM on Wednesday, December 16th. No formal agenda; just good food, good conversation and friends!

We hope to see you there!

12/13/2009 15:50:03 (Eastern Standard Time, UTC-05:00) #     |  Trackback

 

.NET CF Lesson: “SNAPI Fast, ActiveSync Not-So-Much”#
Post By Don Sorcinelli

I thought I would pass along a “good news/bad news” experience I recently had with regards to Windows Mobile 6.5, the .NET Compact Framework 3.5 and ActiveSync. Hopefully, it might serve to help someone in avoiding some coding and testing frustration.

I have been working on a project that requires responding to new incoming messages on Windows Mobile 6.5 devices. Fortunately, the State and Notification Broker API (“SNAPI”) made this simple enough. Now, my C# code needed to play a sound if certain conditions were met. Simple enough – the System.Media.SoundPlayer class in the .NET CF 3.5 would do the trick. Once the code was written, it was time to test.

The first test went according to plan. Use an emulator, deploy in debugging mode, set a breakpoint to ensure that I was hitting the correct branches in application logic and run with it. Sure enough, everything performed as expected. The next test was essentially the same, with the exception being connecting an actual Windows Mobile 6.5 device for testing. Again, there were no problems.

For the next test, I decided to remove the breakpoint in Visual Studio. I run the code and… no sound. My intellectual response - “WTF?!?!?” ;-)

I’ll keep the story brief here, omitting all the second-guessing and testing that went on up until my finally figuring out the root cause of the problem. The issue, as it turns out, is that -

  • SNAPI and the .NET Compact Framework 3.5 work very well. By “well”, I mean “fast”, especially when running on the latest hardware with Windows Mobile 6.5.
  • ActiveSync runs… well… about as fast as it always has on Windows Mobile, despite OS and hardware improvements.

Keeping in mind that ActiveSync and my application run on different threads, here is what I was able to determine:

  • ActiveSync begins a synchronization operation. As part of this sync, a new email arrives. Based upon device settings, ActiveSync prepares to play a sound and grabs resources.
  • At around the same time, my application receives the notification from the broker about a change in the unread email count changing. My logic has to do quite a bit of processing, but still managed to get to the point of playing a sound while ActiveSync still had a hold on resources. Result – my sound wouldn’t play.

“Fine”, I thought, “This is strictly a timing issue.” When I was in debugging mode, the stepping through the code and the latency associated with running in debug mode gave enough time for ActiveSync to complete. As a result, I decided to add code to pause my code to give time for ActiveSync to release resources. Here is where the real surprise came into play.

I spent quite a bit of time tinkering with the amount of time my application had to sleep in order to be able to play my sound. It took upwards of ten seconds for ActiveSync to release the resource I needed. When you consider the fact that ActiveSync had a “head start” on my code (AS was the cause of the SNAPI event firing, mind you), the amount of time from start to finish for AS was, well, A LOT. Ten seconds?!? Needless to say, I was very surprised and disappointed. This wouldn’t have surprised me a few years back, when slower hardware and slower network speeds could be the culprits. But today? With faster hardware and networks?

I guess the moral of this story is… If you are coding for Windows Mobile with a dependency on ActiveSync, NEVER assume performance. Code for the worst case and hope to be pleasantly surprised.

12/11/2009 09:19:08 (Eastern Standard Time, UTC-05:00) #     |  Trackback

 

All content © 2017, Don Sorcinelli
On this page
This site
Facebook
Club Pocket PC - Boston

NEXT MEETING
September 19th, 2012

Stay tuned for details!

Support Our Sponsors!
Calendar
<2017 August>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 1.0.0.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail