I am creating a small game in UWP using C# and a physics library.
After some rather painful debugging, I have discovered that some code has been run behind the scene after a _Click event has been executed. This code needs to fire before my event code has completed.
In other words, this is what I want to happen:
1. user clicks button
2. some code executes via the _Click event
3. the final parts of this code fetches some attributes from a list, regarding the object just added to the list.
What happens now is this:
1. user clicks button
2. some code executes via the _Click event
3. the final part of the code tries to fetch some attributes, but as these haven't been modified yet in the underlying code, my code crashes.
I have no problem waiting a few milliseconds or so before fetching the updated object, so I can easily cut out the final code and place it in a method that runs a little later in time (I'd prefer this to digging into the underlying code library). Thus, I wonder if there is a something similar to a Page_Loaded event, taking place AFTER the underlying code has been updated correctly.
Here is my _Click code. Nothing strange here really. The problem is that the underlying code runs AFTER the closing of this method. I need a way to run more code AFTER that underlying code has finished running.
private void btnAddBomber_Click(object sender, RoutedEventArgs e)
{
ucBomber bomber = new ucBomber();
AddObjectRandomPosition(bomber, 50, 1000, 120, 120, 174, 100);
}
What I have tried:
I have tried to find a suitable event, but to no avail. I am not sure of how to search for this.