Note that there are some explanatory texts on larger screens.

plurals
  1. POTrapping ActiveSyncEnd event:
    text
    copied!<p>I'm writing an app (.NET Compact Framework 3.5 on PocketPc 2003) I'm trying to detect the cradle event, which is detected but is highly erratic. For instance, on every detection the while loop runs twice. Is this because of multiple registrations to the ActiveSyncEnd event? How do I correct this?</p> <pre><code> ///NOTIFICATION_EVENT_NONE = 0, ///NOTIFICATION_EVENT_TIME_CHANGE = 1, ///NOTIFICATION_EVENT_SYNC_END = 2, ///NOTIFICATION_EVENT_ON_AC_POWER = 3, ///NOTIFICATION_EVENT_OFF_AC_POWER = 4, ///NOTIFICATION_EVENT_NET_CONNECT = 5, ///NOTIFICATION_EVENT_NET_DISCONNECT = 6, ///NOTIFICATION_EVENT_DEVICE_CHANGE = 7, ///NOTIFICATION_EVENT_IR_DISCOVERED = 8, ///NOTIFICATION_EVENT_RS232_DETECTED = 9, ///NOTIFICATION_EVENT_RESTORE_END = 10, ///NOTIFICATION_EVENT_WAKEUP = 11, ///NOTIFICATION_EVENT_TZ_CHANGE = 12, ///NOTIFICATION_EVENT_MACHINE_NAME_CHANGE = 13 // In DeviceEventManager public void ActiveSyncEndDetect() { try { // Put 9 for cradle event, 2 for ActiveSyncEnd event, 0 for none. handleActiveSyncEndEvent = NativeMethods.CreateEvent(IntPtr.Zero, false, false, "EventActiveSync"); while (!terminateDeviceEventThreads) { //NativeMethods.CeRunAppAtEvent("\\\\.\\Notifications\\NamedEvents\\EventActiveSync", 2); //NativeMethods.CeRunAppAtEvent("\\\\.\\Notifications\\NamedEvents\\EventActiveSync", 9); NativeMethods.CeRunAppAtEvent("\\\\.\\Notifications\\NamedEvents\\EventActiveSync", 2); NativeMethods.WaitForSingleObject(handleActiveSyncEndEvent, 0xFFFFFFFF); //MessageBox.Show("Activesync ended."); //Do something here NativeMethods.CeRunAppAtEvent("\\\\.\\Notifications\\NamedEvents\\EventActiveSync", 0); } } catch (Exception e) { System.Windows.Forms.MessageBox.Show("Exception in ActiveSyncEndDetect method"); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload