I have some recursive code in my windows10 App (UWP platform) I know that there are no direct way to catch StackOverflowException on C#, but there is a way by using Thread class on Windows Forms API. And I can't apply solution to UWP, because there are no Thread class. So, I have some code and I need to try execute it and stop it's Thread if it's fails. I also want to detect exception if it's possible. User can be satisfied by half finished work. My application is closing if recursion is too big. How to fix someWork(byte[] data) method?
public sealed partial class MainPage : Page {
    private byte[] dataArray; // value is creating by user
    // data can be very big, so not-resursive code can use all App's memory and crush it too!!
    private async void ButtonClick(object sender, RoutedEventArgs ev) { // here I run method
       bool isFinished = someWork(dataArray);
       // then I show dataArray (no matter finished or not) to user
    }
    private static bool someWork(byte[] data) { // I need to fix this method
        int start_arg = 0;
        try {
            someWork_recursive(data, start_arg); 
            return true; // All done
        } catch (Exception) { } // I trying to catch StackOverflowException here
        return false; // Half-finished
    }
    private static void someWork_recursive(byte[] data, int arg) { // My question is NOT about body of this method
        // code that run someWork_recursive() again or not
        // also code that change data[] values
    }
}
