Thread is not ending when atomic variable is changed

I can’t seem to get a loading screen animation to end, despite several attempts to fix the issue. (I used the AI to try and do so)
the loading_screen function is found in the functions folder. (and in other functions relating to loading and saving)

Repl link:

I just realized, but I forgot to say that to find where I am having issues you need to tell the console you have a save and then try to load one of the saves.

In the Load() function, the loading screen is initiated using Startloading(), which (I assume) creates a new thread running loading_screen().
However, loading_screen() is a while loop that runs indefinitely until stopLoading is set to true.

The Stoploading() function, which sets stopLoading to true and joins the thread, is called only after the save file data is read.

You see the problem?
There might be scenarios where the LOAD.close() operation is delayed or stuck due to file I/O issues, leading to the loading screen running indefinitely.

You definitely need more error handling in your code, so I’d suggest you start there.


thanks, I will look into having more error handling.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.