Synchronization with .NET Compact Framework (cont.)

So, suppose we were going to sync over the network whenever we have a network connection(some thoughts on that here), and suppose we have a user that is only connected to the network when he is plugged in to the cradle. How could we ensure that his data will get synchronized when he is cradled, even if our application is no longer running?

I think the answer is in having a console or ‘headless’ sync app. This is an application without a user interface. Whenever our main application is running, we check to see if the headless sync app is running and shut it down. Then, whenever we close our main application, we start up our headless sync app.

The headless sync app will basically detect when it has a network connection, and when it does, sync anything outstanding and shut itself down when finished. It would have to be able to tolerate network connections that did not last long enough to complete the sync operation.

In this way, whenever there was sync work to do, an application (either the main app or the headless sync app) would be running, waiting for a network connection to do the sync. Whenever there was no sync work to do, we would not have any extra applications running.

Of course, the downside of this is that we would have a lingering application running as long as there was sync work to do. That can be seen as bad behavior (I’m looking into whether it would be bad etiquette.).

Also, how do we tell that there is sync work to do? We can tell that the user has inspections to upload, but how can we tell whether there are label changes or a new version of the application to upload? For this problem, we could use the same pattern we use today. We check whenever we are sending something. So, if there are no inspections to send at sync time, there will be no label uploads either. We would probably also want to give the user an opportunity to force this check, or to set up an interval to do the check – e.g. if we haven’t checked for new labels in 1 week, there IS sync work to do. Of course, this would only get updated if the user actually opened the application, so he could be very far behind for one session until his next sync.

We would also have to tolerate the less common case of a user doing a soft reset of the device, killing our headless application before he connects to the cradle.

So those are all the challenges/problems with the idea. What’s the upside? First, we get a background sync in most cases. Users don’t have to remember to sync anything. This background sync can happen at any time the user has a network connection, which would be nice for our wireless users. Last but not least, we don’t have to go through all the ActiveSync headaches.

I’m not necessarily sold on this approach. I could be talked out of it. But for now, it’s my recommendation.