Recent

Author Topic: Any way to kill a wince app trapped in an infinite loop?  (Read 8836 times)

epergola

  • Full Member
  • ***
  • Posts: 157
Any way to kill a wince app trapped in an infinite loop?
« on: November 13, 2009, 05:29:26 am »
Hi
Of course infinite loops MUST be avoied.
However, they are particularly obnoxious in pda.
Consider this: an app runs in full screen, the dreaded infinite loop starts... the screen goes black. Pressing the power button and restarting the device does nothing. A reset, idem. Only a cold boot
saves you, BUT you need to reset many custom settings.
On desktops, at least you can access the task manager and kill the application.
Any suggestion (short of  'infinite loops should never happen, it's bad programming' with which I agree, only the fear of that happening is enough to want to be prepared)  on how to deal with the above. In the freepascal forum someone suggessted some Sendmessage from a secondary thread to the main thread.
But this does not work b/c the Execute method of the custom thread stops being called when the infinite loop in the main app happens.


felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Any way to kill a wince app trapped in an infinite loop?
« Reply #1 on: November 13, 2009, 01:41:44 pm »
Maybe you could call a routine inside all your loops, or at least inside all loops which could cause such a crash. And another call after the loop. So if you stay in the loop for more then 10.000 calls without a end-loop call, then call Halt(0) to kill the application. This should work for loops in your code.

Code: [Select]
loop X
  LoopIteration();
end;
LoopEnd();

var
  gLoopCount: Cardinal = 0;

procedure LoopIteration();
begin
  Inc(gLoopCount);
  if gLoopCount > 10000 then Halt(0);
end;

procedure EndLoop();
begin
  gLoopCount := 0;
end;

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
Re: Any way to kill a wince app trapped in an infinite loop?
« Reply #2 on: November 14, 2009, 03:15:07 pm »
If your system is stuck, only you can make could reset
or this tools
http://madebits.com/tools/pocketpc-process-explorer.php

kees

  • New Member
  • *
  • Posts: 13
Re: Any way to kill a wince app trapped in an infinite loop?
« Reply #3 on: November 16, 2009, 01:57:23 pm »
Nice tool, unfortunately it doesn't work on PocketPC 6.1  %)
It does start up, but "Cannot get process information"

 

TinyPortal © 2005-2018