The problem with automatic that I've had is the library's (opennetcf)
inability to determine whether a device is connected or not. You first
have to try to establish a connection, then check for whether that
connection worked...
As follows:
OpenNETCF.Desktop.Communication.RAPI desktopComm = new
OpenNETCF.Desktop.Communication.RAPI();
desktopComm.Connect ();
if ( !desktopComm.DevicePresent )
{
// do your synchronisation here
}
desktopComm.Disconnect();
The catch is, if you call Connect(), and there's no device present, it
just hangs. The timeout option that comes with the method doesn't seem to
work. I suppose if you were running a windows service that checked
every
few seconds for a connection then you could spawn a thread to check,
and
have the main thread abort this new thread should with your own time
out
mechanism. I'm not sure how reliable this would be though.
The manual part of this is easy, simply ask the user to ensure a device is
connected, and that active sync has established a connection, then perform
your synchronisation. This is better as it also allows you the oppurtunity
to ask the user to insure the database file isn't locked or currently
in
use...
Good luck.
Dan.
The goal when I put device into a cradle, I need to update SqlCe
sdf
file
in it.
Automatically (as soon as you're docked and connected) or manually (with
the
click of a button or something to that affect)?
Automatically would be better. But manually is also possible.