static void Main(string[] args) { try { T.Initialize("urbemobile"); T.CurrentLevel = 0; Net.TCP.Stream.StreamTraceLevel = 0; var appDomain = AppDomain.CurrentDomain; appDomain.UnhandledException += appDomain_UnhandledException; if (Math.Abs(CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, -1)) == 1) { T.ResetFileOnStartup = ConfigurationManager.AppSettings["hack_dont_reset_log"] == "active" ? false : true; UnattendedMain(args); }/* * else * { * MessageBox.Show("MAIN: es imposible activar modo inatendido, urbemobile no va a ejecutarse."); * }*/ CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, 0); } catch (Exception e) { T.EXCEPTION(e, "main"); T.DEAD_REPORT(e); } }
private void stopUmtMenuItem_Click(object sender, EventArgs e) { umtRun.Reset(); if (nullIntPtr != wavPowerReqHandle) { CoreDLL.ReleasePowerRequirement(wavPowerReqHandle); wavPowerReqHandle = nullIntPtr; } CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, 0); }
private void startUmtMenuItem_Click(object sender, EventArgs e) { // See Unattended Mode example at http://stackoverflow.com/questions/336771/how-can-i-run-code-on-windows-mobile-while-being-suspended CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, 1); // Request that the audio device remain powered in unattended mode // NOTE: If you don't do this, the system suspends anyway 1 minute after you press the power button // (USB reader power light goes out, system publishes a Suspend notification.) // With this request, it seems to run indefinitely. wavPowerReqHandle = CoreDLL.SetPowerRequirement("wav1:", CEDeviceDriverPowerStates.D0, DevicePowerFlags.POWER_NAME | DevicePowerFlags.POWER_FORCE, new IntPtr(0), 0); umtRun.Set(); }