UWP App Locks After Returning From Other Apps

Nathan Sokalski 4,111 Reputation points
2020-02-05T02:31:42.673+00:00

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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.