Calling Main Draw routine.

Hello again!

I have a point in a game where I change scene. This involves loading and processing a few hundred SQLite datarows. This obviously takes some time, there is actually quite a lot going on.

I would really like to quickly load the data table and make a call to a routine to process a row at a time within the normal sequence of events, but this just isn’t possible due to data clashes that would occur throughout the rest of the app.

So, how, if at all, can I call the Draw routine while I’m working through the list of items? At least then I’ll be able to show the user some progress rather than a locked screen for a couple of seconds.

Or, have any of you folks tackled this in a different way?

Calling the draw routine would just redraw the static screen. You want to show progress so you have to call update as well. I solved that problem with a worker thread (multithreading).
If you don’t want to go down that road you could try to split your calculations into parts (that’s not always possible) and do them in consecutive update calls while updating progress.

Here is a TaskManagerComponent I made a while ago: This monogame component helps handling task execution in a background thread, and synchronization in the game thread. · GitHub

After registering the component on Game Initialization, you can execute background tasks, like so:

taskManager.ExecuteInBackground(() =>
{
//execute something heavy in background thread
System.Threading.Thread.Sleep(2000);

            return Color.Aqua; // return color
        }).Then(r =>
        {
            //Here we are back in the game thread, OnUpdate()
           var clearColor = r.Result;
            // Result returns Color.Aqua
        });