UWP App Locks After Returning From Other Apps

Nathan Sokalski 4,001 Reputation points

When a user leaves my app (not closes, just leaves, triggering the EnteredBackground event), does something in another app, and then returns (triggering the LeavingBackground event), I receive an InvalidOperationException and my app locks up. The app no longer responds to click, touch, etc., and it does not let me close it. I am forced to open Task Manager to close the app. I am not sure specifically what is causing the InvalidOperationException, so I am not sure how to determine the details. I handle OnSuspending & override OnLaunched to save & restore state, but what should I do to allow the user to leave and return to my app without causing it to lock up? Thanks.

Universal Windows Platform (UWP)
{count} votes