Monday, August 20, 2012

CheckForIllegalCrossThreadCalls on MonoTouch 5.99

One of the first things I encountered after I upgraded to iOS6 (beta 4) and MonoTouch 5.99.2 was that my app would crash intermittently at random places. That got me quite worried, but a bit of googling reveals that this is because of a new feature in MonoTouch 6.0.

So the new version of MonoTouch will check for illegal cross thread calls and crash your app if its been naughty! The property UIApplication.CheckForIllegalCrossThreadCalls defaults to true for DEBUG ONLY. This is meant to educate the developers to fix the illegal cross thread calls.
If you are after a quick fix, you can do this in your AppDelegate FinishedLaunching method:

public override void FinishedLaunching (UIApplication app)
    UIApplication.CheckForIllegalCrossThreadCalls = false;

    // your other init code here ...

However beware that the correct thing to do will be to fix your actual code!

No comments:

Post a Comment