How to create a crash report when the app is hung
Update
There is a much easier way to do this. All iOS versions and devices include a way to force quit an application:
- Hold down the On/Off button until "slide to power off" appears.
- Release the On/Off button.
- Hold down the Home button.
- After a few seconds the app will be terminated, and a crash report will be generated (the app's exception code will be 0xdeadfa11).
public class Application { [System.Runtime.InteropServices.DllImport ("libc")] static extern int strlen (IntPtr zero); static unsafe void Tick () { int zero = 0; int* z = &zero; // This is so that strlen is initialized // (so no/fewer locks are required later) strlen ((IntPtr) z); // The sleep interval can be modified to sleep // until you're sure the app has hung. System.Threading.Thread.Sleep (30000); // Create a crash report strlen (IntPtr.Zero); } static void Main (string[] args) { new System.Threading.Thread (Tick).Start (); UIApplication.Main (args, null, "AppDelegate"); } }